Struct std::sync::atomic::AtomicOptionDeprecated
[-]
[+]
[src]
pub struct AtomicOption<T> { // some fields omitted }
An atomic, nullable unique pointer
This can be used as the concurrency primitive for operations that transfer owned heap objects across tasks.
Methods
impl<T: Send> AtomicOption<T>
fn new(p: Box<T>) -> AtomicOption<T>
Create a new AtomicOption
fn empty() -> AtomicOption<T>
Create a new AtomicOption
that doesn't contain a value
fn swap(&self, val: Box<T>, order: Ordering) -> Option<Box<T>>
Store a value, returning the old value
fn take(&self, order: Ordering) -> Option<Box<T>>
Remove the value, leaving the AtomicOption
empty.
fn fill(&self, val: Box<T>, order: Ordering) -> Option<Box<T>>
Replace an empty value with a non-empty value.
Succeeds if the option is None
and returns None
if so. If
the option was already Some
, returns Some
of the rejected
value.
fn is_empty(&self, order: Ordering) -> bool
Returns true
if the AtomicOption
is empty.
Be careful: The caller must have some external method of ensuring the result does not get invalidated by another task after this returns.