From e98635ad8f9015f3749a8d90099ebd37bfb8100c Mon Sep 17 00:00:00 2001 From: Mica White Date: Fri, 8 Mar 2024 15:34:07 -0500 Subject: Allow moves --- src/key.rs | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'src/key.rs') diff --git a/src/key.rs b/src/key.rs index 92f3b99..0297bc1 100644 --- a/src/key.rs +++ b/src/key.rs @@ -22,12 +22,6 @@ static KEY: Lazy> = Lazy::new(ThreadLocal::new); /// [`ThreadKey::lock`]. If the `ThreadKey` is dropped, it can be reobtained. pub type ThreadKey = Key<'static>; -/// A dumb lock that's just a wrapper for an [`AtomicBool`]. -#[derive(Debug, Default)] -pub struct AtomicLock { - is_locked: AtomicBool, -} - pub struct Key<'a> { phantom: PhantomData<*const ()>, // implement !Send and !Sync lock: &'a AtomicLock, @@ -76,20 +70,13 @@ impl ThreadKey { } } -impl AtomicLock { - /// Create a new unlocked `AtomicLock`. - #[must_use] - pub const fn new() -> Self { - Self { - is_locked: AtomicBool::new(false), - } - } - - /// Checks whether this `Lock` is currently locked. - pub fn is_locked(&self) -> bool { - self.is_locked.load(Ordering::Relaxed) - } +/// A dumb lock that's just a wrapper for an [`AtomicBool`]. +#[derive(Debug, Default)] +struct AtomicLock { + is_locked: AtomicBool, +} +impl AtomicLock { /// Attempt to lock the `AtomicLock`. /// /// If the lock is already locked, then this'll return false. If it is -- cgit v1.2.3