diff --git a/Cargo.toml b/Cargo.toml index 5d10f87..1405416 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ generic_once_cell = "0.1" interrupts = "0.1" interrupt-mutex = "0.1" lock_api = "0.4" +one-shot-mutex = "0.1.1" spinning_top = "0.3" [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index c19b155..01d8583 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,17 +70,20 @@ //! //! This crate provides a lot of type definitions for ease of use: //! -//! | [`RawMutex`] | Base | With [`RawInterruptMutex`] | -//! | ------------------ | -------------------- | ----------------------------- | -//! | `R` | [`Mutex`] | [`InterruptMutex`] | -//! | [`RawSpinMutex`] | | [`RawInterruptSpinMutex`] | -//! | | [`SpinMutex`] | [`InterruptSpinMutex`] | -//! | | [`SpinMutexGuard`] | [`InterruptSpinMutexGuard`] | -//! | | [`OnceCell`] | [`InterruptOnceCell`] | -//! | | [`Lazy`] | [`InterruptLazy`] | -//! | [`RawTicketMutex`] | | [`RawInterruptTicketMutex`] | -//! | | [`TicketMutex`] | [`InterruptTicketMutex`] | -//! | | [`TicketMutexGuard`] | [`InterruptTicketMutexGuard`] | +//! | [`RawMutex`] | Base | With [`RawInterruptMutex`] | +//! | ------------------- | --------------------- | ------------------------------ | +//! | `R` | [`Mutex`] | [`InterruptMutex`] | +//! | [`RawSpinMutex`] | | [`RawInterruptSpinMutex`] | +//! | | [`SpinMutex`] | [`InterruptSpinMutex`] | +//! | | [`SpinMutexGuard`] | [`InterruptSpinMutexGuard`] | +//! | | [`OnceCell`] | [`InterruptOnceCell`] | +//! | | [`Lazy`] | [`InterruptLazy`] | +//! | [`RawOneShotMutex`] | | [`RawInterruptOneShotMutex`] | +//! | | [`OneShotMutex`] | [`InterruptOneShotMutex`] | +//! | | [`OneShotMutexGuard`] | [`InterruptOneShotMutexGuard`] | +//! | [`RawTicketMutex`] | | [`RawInterruptTicketMutex`] | +//! | | [`TicketMutex`] | [`InterruptTicketMutex`] | +//! | | [`TicketMutexGuard`] | [`InterruptTicketMutexGuard`] | //! //! [`RawMutex`]: lock_api::RawMutex //! [`Mutex`]: lock_api::Mutex @@ -113,9 +116,14 @@ pub use interrupts::without as without_interrupts; pub use mutex::spin::{RawSpinMutex, SpinMutex, SpinMutexGuard}; pub use mutex::ticket::{RawTicketMutex, TicketMutex, TicketMutexGuard}; pub use mutex::{ - InterruptSpinMutex, InterruptSpinMutexGuard, InterruptTicketMutex, InterruptTicketMutexGuard, + InterruptOneShotMutex, InterruptOneShotMutexGuard, InterruptSpinMutex, InterruptSpinMutexGuard, + InterruptTicketMutex, InterruptTicketMutexGuard, RawInterruptOneShotMutex, RawInterruptSpinMutex, RawInterruptTicketMutex, }; +pub use one_shot_mutex::{ + OneShotMutex, OneShotMutexGuard, OneShotRwLock, OneShotRwLockReadGuard, + OneShotRwLockUpgradableReadGuard, OneShotRwLockWriteGuard, RawOneShotMutex, RawOneShotRwLock, +}; pub use rwlock::{ RawRwSpinLock, RwSpinLock, RwSpinLockReadGuard, RwSpinLockUpgradableReadGuard, RwSpinLockWriteGuard, diff --git a/src/mutex/mod.rs b/src/mutex/mod.rs index b148ae7..9d3bcce 100644 --- a/src/mutex/mod.rs +++ b/src/mutex/mod.rs @@ -11,9 +11,19 @@ pub(crate) mod spin { pub(crate) mod ticket; use interrupt_mutex::RawInterruptMutex; +use one_shot_mutex::RawOneShotMutex; use spin::RawSpinMutex; use ticket::RawTicketMutex; +/// An interrupt-safe [`RawOneShotMutex`]. +pub type RawInterruptOneShotMutex = RawInterruptMutex; + +/// A [`lock_api::Mutex`] based on [`RawInterruptOneShotMutex`]. +pub type InterruptOneShotMutex = lock_api::Mutex; + +/// A [`lock_api::MutexGuard`] based on [`RawInterruptOneShotMutex`]. +pub type InterruptOneShotMutexGuard<'a, T> = lock_api::MutexGuard<'a, RawInterruptOneShotMutex, T>; + /// An interrupt-safe [`RawSpinMutex`]. pub type RawInterruptSpinMutex = RawInterruptMutex;