diff --git a/Cargo.toml b/Cargo.toml index 96df90f..c6e4dbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,3 +20,6 @@ spinning_top = "0.3" [dev-dependencies] rand = "0.8" + +[features] +all-one-shot = [] diff --git a/src/mutex/mod.rs b/src/mutex/mod.rs index 9d3bcce..62f301c 100644 --- a/src/mutex/mod.rs +++ b/src/mutex/mod.rs @@ -1,3 +1,4 @@ +#[cfg(not(feature = "all-one-shot"))] pub(crate) mod spin { /// A simple spinlock with exponential backoff. pub type RawSpinMutex = spinning_top::RawSpinlock; @@ -8,7 +9,22 @@ pub(crate) mod spin { /// A [`lock_api::MutexGuard`] based on [`RawSpinMutex`]. pub type SpinMutexGuard<'a, T> = lock_api::MutexGuard<'a, RawSpinMutex, T>; } +#[cfg(feature = "all-one-shot")] +pub(crate) mod spin { + pub use one_shot_mutex::{ + OneShotMutex as SpinMutex, OneShotMutexGuard as SpinMutexGuard, + RawOneShotMutex as RawSpinMutex, + }; +} +#[cfg(not(feature = "all-one-shot"))] pub(crate) mod ticket; +#[cfg(feature = "all-one-shot")] +pub(crate) mod ticket { + pub use one_shot_mutex::{ + OneShotMutex as TicketMutex, OneShotMutexGuard as TicketMutexGuard, + RawOneShotMutex as RawTicketMutex, + }; +} use interrupt_mutex::RawInterruptMutex; use one_shot_mutex::RawOneShotMutex;