[src]

Struct std::sync::atomics::AtomicOption

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> AtomicOption<T>

fn new(p: ~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: ~T, order: Ordering) -> Option<~T>

Store a value, returning the old value

fn take(&self, order: Ordering) -> Option<~T>

Remove the value, leaving the AtomicOption empty.

fn fill(&self, val: ~T, order: Ordering) -> Option<~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.

Trait Implementations

impl<T> Drop for AtomicOption<T>

fn drop(&mut self)

The drop method, called when the value goes out of scope.