pub trait SyncCell<T> {
// Required methods
fn from_value(value: T) -> Self;
fn get_mut(&mut self) -> &mut T;
fn try_with<U>(&self, f: impl FnOnce(&T) -> U) -> Option<U>;
fn try_store(&self, value: T) -> Result<(), T>;
// Provided method
fn swap(&self, value: T) { ... }
}Expand description
A thread-safe cell that can be used as atomic for any type.
It is already implemented for NaiveRWLock, std::sync::Mutex, std::sync::RwLock.
Required Methods§
Sourcefn from_value(value: T) -> Self
fn from_value(value: T) -> Self
Creates a new SyncCell with the given value.
Provided Methods§
Sourcefn swap(&self, value: T)
fn swap(&self, value: T)
Tries to store the value using busy-waiting with Backoff.
For LockFreeSyncCell, this method never blocks.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.