2 releases (1 stable)
1.0.0 | Jan 31, 2025 |
---|---|
0.1.0 | Jul 22, 2024 |
#120 in Concurrency
682 downloads per month
40KB
472 lines
mutex
When a mutex and a closure love each other very much.
Mutex implementations using mutex-traits
.
Versioning, and which crate to use?
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.
Crate Feature Flags
The following feature flags enable implementations of
mutex_traits::ScopedRawMutex
and
mutex_traits::RawMutex
:
impl-critical-section
(default:true
): Enables implementations ofScopedRawMutex
for thecritical-section
crate.impl-lock_api-0_4
(default:false
): Enables a wrapper type implementingRawMutex
for types implementing thelock_api
crate'sRawMutex
trait.impl-unsafe-cortex-m-single-core
(default:false
): Enables implementations ofScopedRawMutex
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 requireliballoc
. -
fmt
(default:false
): Enables implementations ofcore::fmt::Debug
andcore::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.
Provenance
Portions of this code are forked from the embassy-sync
crate.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
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.
Dependencies
~46KB