pub struct AccessCell<T> { /* private fields */ }Expand description
A cell holding a value of type T with re-entrant mutable access.
The first caller of access runs immediately; any further
calls to access from within that closure (or its queue) are enqueued and
executed in order after the current work completes.
Implementations§
Source§impl<T> AccessCell<T>
impl<T> AccessCell<T>
Sourcepub fn access(&self, f: impl FnOnce(&mut T) + 'static)
pub fn access(&self, f: impl FnOnce(&mut T) + 'static)
Runs f with exclusive mutable access to the inner value.
If called while another access closure is running (re-entrant call),
f is queued and run after the current closure and any other queued
closures finish.
Sourcepub fn access_mut(&self) -> &mut T
pub fn access_mut(&self) -> &mut T
Returns a mutable reference to the inner value.
§Safety
Only call this while you are inside an access closure (or while draining
the queue). Otherwise you may create aliasing mutable references.
Sourcepub fn access_ref(&self) -> &T
pub fn access_ref(&self) -> &T
Returns an immutable reference to the inner value.
Safe to call at any time; no closure is running when you use this for read-only access.