summaryrefslogtreecommitdiff
path: root/src/key.rs
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2024-03-08 15:34:07 -0500
committerMica White <botahamec@outlook.com>2024-03-08 15:34:07 -0500
commite98635ad8f9015f3749a8d90099ebd37bfb8100c (patch)
tree31aed6268ffcdad0407fa48e52d79ca288a216b3 /src/key.rs
parent44347114329545f6b53a621e09a596c53884413a (diff)
Allow moves
Diffstat (limited to 'src/key.rs')
-rw-r--r--src/key.rs25
1 files changed, 6 insertions, 19 deletions
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<ThreadLocal<AtomicLock>> = 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