From 0b49b056981f4c5bcbdbb7fada1a8379e0793c86 Mon Sep 17 00:00:00 2001 From: Botahamec Date: Fri, 28 Oct 2022 22:20:05 -0400 Subject: Implemented SpinLock --- src/lock.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/lock.rs') 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); } -- cgit v1.2.3