https://github.com/finnbear/maybe_atomic_refcell
AtomicRefcell for debug mode and UnsafeCell in release mode.
https://github.com/finnbear/maybe_atomic_refcell
atomic refcell rust rust-crate rust-lang synchronization
Last synced: about 1 year ago
JSON representation
AtomicRefcell for debug mode and UnsafeCell in release mode.
- Host: GitHub
- URL: https://github.com/finnbear/maybe_atomic_refcell
- Owner: finnbear
- License: mit
- Created: 2022-05-28T02:34:57.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-28T03:49:33.000Z (about 4 years ago)
- Last Synced: 2025-03-29T08:51:10.459Z (about 1 year ago)
- Topics: atomic, refcell, rust, rust-crate, rust-lang, synchronization
- Language: Rust
- Homepage: https://crates.io/crates/maybe_atomic_refcell
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# maybe_atomic_refcell
[`AtomicRefCell`](https://github.com/bholley/atomic_refcell) for `debug` mode and [`UnsafeCell`](https://doc.rust-lang.org/stable/std/cell/struct.UnsafeCell.html) in `release` mode.
## Motivation
`AtomicRefCell` performs an atomic memory access at runtime to validate borrowing. While
this is an excellent way to validate code and ensure safety, it is an expensive
operation. This crate delegates to `AtomicRefCell` in `debug` mode and uses `UnsafeCell` to
emulate the same interface in `release` mode, minus the runtime overhead.
## Features
- `safe` enables unconditional runtime checks, good for validating in `release` mode
## Limitations
- No try-borrows, as they are impossible to (properly) implement without overhead
- `borrow` and `borrow_mut` are `unsafe` (despite being safe in `debug` mode)
- No `PartialEq`, `Eq`, `PartialOrd`, `Ord`, etc. due to the above
## 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.