summaryrefslogtreecommitdiff
path: root/src/lock.rs
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2022-10-28 22:20:05 -0400
committerBotahamec <botahamec@outlook.com>2022-10-28 22:20:05 -0400
commit0b49b056981f4c5bcbdbb7fada1a8379e0793c86 (patch)
treef0f03db59a7286a421aafad31c062ed1edd64885 /src/lock.rs
parentd00df37bc92fccaa39e69bf886f9c8cd5522817b (diff)
Implemented SpinLock
Diffstat (limited to 'src/lock.rs')
-rw-r--r--src/lock.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lock.rs b/src/lock.rs
index c69ce21..101a061 100644
--- a/src/lock.rs
+++ b/src/lock.rs
@@ -38,6 +38,11 @@ impl Lock {
}
}
+ /// Checks whether this `Lock` is currently locked.
+ pub fn is_locked(&self) -> bool {
+ self.is_locked.load(Ordering::Relaxed)
+ }
+
/// Attempt to lock the `Lock`.
///
/// If the lock is already locked, then this'll return false. If it is
@@ -56,7 +61,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.
- unsafe fn force_unlock(&self) {
+ pub unsafe fn force_unlock(&self) {
self.is_locked.store(false, Ordering::Release);
}