https://github.com/mkroening/one-shot-mutex
One-shot locks that panic instead of (dead)locking on contention.
https://github.com/mkroening/one-shot-mutex
deadlock mutex no-std rust single-thread
Last synced: 6 months ago
JSON representation
One-shot locks that panic instead of (dead)locking on contention.
- Host: GitHub
- URL: https://github.com/mkroening/one-shot-mutex
- Owner: mkroening
- License: apache-2.0
- Created: 2024-04-03T10:59:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-21T09:47:23.000Z (7 months ago)
- Last Synced: 2025-04-14T20:15:51.522Z (6 months ago)
- Topics: deadlock, mutex, no-std, rust, single-thread
- Language: Rust
- Homepage: https://docs.rs/one-shot-mutex
- Size: 81.1 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# one-shot-mutex
[](https://crates.io/crates/one-shot-mutex)
[](https://docs.rs/one-shot-mutex)
[](https://github.com/mkroening/one-shot-mutex/actions/workflows/ci.yml)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.```rust
use one_shot_mutex::sync::OneShotMutex;static X: OneShotMutex = 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].
[docs]: https://docs.rs/one-shot-mutex
## License
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license
([LICENSE-MIT](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.