mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 22:15:07 +01:00
added doc for RacyCell
This commit is contained in:
parent
8065d741ac
commit
1e2ab78a3f
1 changed files with 21 additions and 0 deletions
21
src/lib.rs
21
src/lib.rs
|
@ -59,6 +59,27 @@ where
|
||||||
use core::cell::UnsafeCell;
|
use core::cell::UnsafeCell;
|
||||||
|
|
||||||
/// Internal replacement for `static mut T`
|
/// Internal replacement for `static mut T`
|
||||||
|
///
|
||||||
|
/// Used to represent RTIC Resources
|
||||||
|
///
|
||||||
|
/// Soundness:
|
||||||
|
/// 1) Unsafe API for internal use only
|
||||||
|
/// 2) get_mut(&self) -> *mut T
|
||||||
|
/// returns a raw mutable pointer to the inner T
|
||||||
|
/// casting to &mut T is under control of RTIC
|
||||||
|
/// RTIC ensures &mut T to be unique under Rust aliasing rules.
|
||||||
|
///
|
||||||
|
/// Implementation uses the underlying UnsafeCell<T>
|
||||||
|
/// self.0.get() -> *mut T
|
||||||
|
///
|
||||||
|
/// 3) get(&self) -> *const T
|
||||||
|
/// returns a raw immutable (const) pointer to the inner T
|
||||||
|
/// casting to &T is under control of RTIC
|
||||||
|
/// RTIC ensures &T to be shared under Rust aliasing rules.
|
||||||
|
///
|
||||||
|
/// Implementation uses the underlying UnsafeCell<T>
|
||||||
|
/// self.0.get() -> *mut T, demoted to *const T
|
||||||
|
///
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct RacyCell<T>(UnsafeCell<T>);
|
pub struct RacyCell<T>(UnsafeCell<T>);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue