Crates.io | one-shot-mutex |
lib.rs | one-shot-mutex |
version | 0.1.1 |
source | src |
created_at | 2024-04-03 11:51:26.798525 |
updated_at | 2024-04-04 12:21:05.421786 |
description | One-shot locks that panic instead of (dead)locking on contention. |
homepage | |
repository | https://github.com/mkroening/one-shot-mutex |
max_upload_size | |
id | 1194993 |
size | 29,629 |
One-shot locks that panic instead of (dead)locking on contention.
These locks allow no contention and panic instead of blocking on lock
if they are already locked.
This is useful in situations where contention would be a bug, such as in single-threaded programs that would deadlock on contention.
use one_shot_mutex::OneShotMutex;
static X: OneShotMutex<i32> = OneShotMutex::new(42);
let x = X.lock();
// This panics instead of deadlocking.
// let x2 = X.lock();
// Once we unlock the mutex, we can lock it again.
drop(x);
let x = X.lock();
For API documentation, see the docs.
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.