From d00df37bc92fccaa39e69bf886f9c8cd5522817b Mon Sep 17 00:00:00 2001 From: Botahamec Date: Thu, 27 Oct 2022 22:43:08 -0400 Subject: Created the Mutex type --- src/lib.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 0f0e330..615086d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ #![warn(clippy::pedantic)] #![warn(clippy::nursery)] +#![allow(clippy::module_name_repetitions)] use std::any::type_name; use std::fmt::{self, Debug}; @@ -9,9 +10,12 @@ use once_cell::sync::Lazy; use thread_local::ThreadLocal; mod lock; +pub mod mutex; use lock::{Key, Lock}; +pub use mutex::Mutex; + static KEY: Lazy> = Lazy::new(ThreadLocal::new); /// The key for the current thread. @@ -50,15 +54,4 @@ 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(); - } } -- cgit v1.2.3