| Crates.io | mutex |
| lib.rs | mutex |
| version | 1.0.2 |
| created_at | 2024-07-22 20:39:01.685178+00 |
| updated_at | 2025-07-06 11:55:27.18354+00 |
| description | An abstraction over closure-based mutexes |
| homepage | |
| repository | https://github.com/tosc-rs/scoped-mutex |
| max_upload_size | |
| id | 1311872 |
| size | 39,979 |
When a mutex and a closure love each other very much.
Mutex implementations using mutex-traits.
The mutex-traits crate should be used by library crates that want to be generic
over different ways of exclusive access.
The mutex crate should be used by applications that need to select which implementation
is appropriate for their use case. The mutex crate also re-exports the mutex-traits
crate for convenience, so applications only need to pull in one direct dependency.
While both crates are >= 1.0, it should be expected that it is more likely that mutex crate
will make breaking changes someday. The hope is that mutex-traits NEVER releases a 2.0
version, which means that even if there are 1.x, 2.x, 3.x, etc. versions of the mutex crate,
they all can be used interchangably since they implement the 1.x mutex-traits interfaces.
If you are a library crate, consider ONLY relying on the mutex-traits crate directly, and
put any use of the mutex crate behind a feature flag or in the dev-dependencies section.
The following feature flags enable implementations of
mutex_traits::ScopedRawMutex and
mutex_traits::RawMutex:
impl-critical-section (default: true): Enables implementations of
ScopedRawMutex for the critical-section crate.impl-lock_api-0_4 (default: false): Enables a wrapper type
implementing RawMutex for types implementing the lock_api crate's
RawMutex trait.impl-unsafe-cortex-m-single-core (default: false): Enables
implementations of ScopedRawMutex which may only be used on single-core
Cortex-M devices.In addition, this crate exposes the following additional feature flags, for
functionality other than implementations of ScopedRawMutex/RawMutex:
std (default: false): Enables features that require the Rust standard
library.
When this feature flag is disabled, this crate compiles with
#![no_std] and does not require liballoc.
fmt (default: false): Enables implementations of core::fmt::Debug
and core::fmt::Display for types provided by this crate.
These formatting trait impls are feature-flagged so that they can be disabled by embedded projects and other use-cases where minimizing binary size is important.
Portions of this code are forked from the embassy-sync crate.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.