Struct basedrop::SharedCell [−][src]
pub struct SharedCell<T> { /* fields omitted */ }
Expand description
A thread-safe shared mutable memory location that holds a Shared<T>
.
SharedCell
is designed to be low-overhead for readers at the expense of
somewhat higher overhead for writers.
Implementations
Constructs a new SharedCell
containing value
.
Examples
use basedrop::{Collector, Shared, SharedCell}; let collector = Collector::new(); let three = Shared::new(&collector.handle(), 3); let cell = SharedCell::new(three);
Replaces the contained Shared<T>
, decrementing its reference count
in the process.
Examples
use basedrop::{Collector, Shared, SharedCell}; let collector = Collector::new(); let x = Shared::new(&collector.handle(), 3); let cell = SharedCell::new(x); let y = Shared::new(&collector.handle(), 4); cell.set(y);
Consumes the SharedCell
and returns the contained Shared<T>
. This
is safe because we are guaranteed to be the only holder of the
SharedCell
.
Examples
use basedrop::{Collector, Shared, SharedCell}; let collector = Collector::new(); let x = Shared::new(&collector.handle(), 3); let cell = SharedCell::new(x); let x = cell.into_inner();
Trait Implementations
Auto Trait Implementations
impl<T> Unpin for SharedCell<T> where
T: Unpin,