| Crates.io | embedded_mutex |
| lib.rs | embedded_mutex |
| version | 0.1.0 |
| created_at | 2025-08-21 23:37:53.348051+00 |
| updated_at | 2025-08-21 23:37:53.348051+00 |
| description | A minimal, no_std, non-blocking mutex for embedded Rust. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1805616 |
| size | 4,537 |
A minimal, no_std-friendly, non-blocking mutex for embedded Rust.
EmbeddedMutex<T> provides a very lightweight mutual exclusion primitive
for no_std environments where you want to avoid blocking and have full
control over when the lock is released.
⚠ Safety notice: This is a low-level primitive. The try_get method is
unsafe because it hands out a &mut T without tying its lifetime to a guard.
You must manually release the lock by calling return_mutex
once you are done.
#![no_std] compatibletry_get acquisition#![no_std]
use embedded_mutex::EmbeddedMutex;
static MY_MUTEX: EmbeddedMutex<u32> = EmbeddedMutex::new(0);
fn example_usage() {
unsafe {
if let Some(data) = MY_MUTEX.try_get() {
*data += 1;
// IMPORTANT: release the mutex when done
MY_MUTEX.return_mutex();
}
}
}