Skip to content

Commit

Permalink
feat: add all-one-shot feature
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Apr 4, 2024
1 parent 1551451 commit 16b7d02
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ spinning_top = "0.3"

[dev-dependencies]
rand = "0.8"

[features]
all-one-shot = []
16 changes: 16 additions & 0 deletions src/mutex/mod.rs
Original file line number Diff line number Diff line change
@@ -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<spinning_top::relax::Backoff>;
Expand All @@ -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;
Expand Down

0 comments on commit 16b7d02

Please sign in to comment.