diff options
| -rw-r--r-- | src/lib.rs | 11 | ||||
| -rw-r--r-- | src/lock.rs | 2 |
2 files changed, 12 insertions, 1 deletions
@@ -50,4 +50,15 @@ impl ThreadKey { pub fn unlock(key: Self) { drop(key); } + + /// Unlocks the `ThreadKey` without consuming it. + /// + /// # Safety + /// + /// This should only be called if the `ThreadKey` to the lock has been + /// "lost". That means the program no longer has a reference to the key, + /// but it has not been dropped. + pub unsafe fn force_unlock() { + KEY.get_or_default().force_unlock(); + } } diff --git a/src/lock.rs b/src/lock.rs index 54a836d..08e21c4 100644 --- a/src/lock.rs +++ b/src/lock.rs @@ -57,7 +57,7 @@ impl Lock { /// This should only be called if the key to the lock has been "lost". That /// means the program no longer has a reference to the key, but it has not /// been dropped. - unsafe fn force_unlock(&self) { + pub unsafe fn force_unlock(&self) { self.is_locked.store(false, Ordering::Release); } |
