pub struct DynamicMutex<T: ?Sized> {
data: UnsafeCell<RefCell<T>>,
}
Expand description
DynamicMutex
implements a guard that is safe for “concurrent” data access on single-core
devices that can only experience non-atomic data access via interrupts. It restricts data
access to within a CriticalSection
, which can only be obtained within a closure given to
without_interrupts
.
The data is wrapped in a core::cell::RefCell
for mutability, which is dynamically checked for
consistency and can lead to a panic. Whenever possible, it is recommended to use a Mutex
instead, which is based on a Cell
.
Fields§
§data: UnsafeCell<RefCell<T>>
Implementations§
source§impl<T: Sized> DynamicMutex<T>
impl<T: Sized> DynamicMutex<T>
source§impl<T: ?Sized> DynamicMutex<T>
impl<T: ?Sized> DynamicMutex<T>
sourcepub fn lock<'access_time>(
&'access_time self,
_cs: &'access_time CriticalSection
) -> &'access_time RefCell<T>
pub fn lock<'access_time>(
&'access_time self,
_cs: &'access_time CriticalSection
) -> &'access_time RefCell<T>
Get uninterrupted access to the encapsulated data. Can only be called inside a
CriticalSection
, ensured by requiring a reference to one.
Trait Implementations§
impl<T> Sync for DynamicMutex<T>where
T: Send,
Auto Trait Implementations§
impl<T> !RefUnwindSafe for DynamicMutex<T>
impl<T: ?Sized> Send for DynamicMutex<T>where
T: Send,
impl<T: ?Sized> Unpin for DynamicMutex<T>where
T: Unpin,
impl<T: ?Sized> UnwindSafe for DynamicMutex<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more