[][src]Struct atomic_take::AtomicTake

pub struct AtomicTake<T> { /* fields omitted */ }

A container with an atomic take operation.


impl<T> AtomicTake<T>[src]

pub fn new(value: T) -> Self[src]

Create a new AtomicTake with the given value.

pub fn empty() -> Self[src]

Create an empty AtomicTake that contains no value.

pub fn take(&self) -> Option<T>[src]

Takes out the value from this AtomicTake. It is guaranteed that exactly one caller will receive the value and all others will receive None.

pub fn take_mut(&mut self) -> Option<T>[src]

This methods does the same as take, but does not use an atomic swap.

This is safe because you cannot call this method without unique access to the AtomicTake, so no other threads will try to take it concurrently.

pub fn is_taken(&self) -> bool[src]

Check whether the value is taken. Note that if this returns false, then this is immediately stale if another thread could be concurrently trying to take it.

pub fn insert(&mut self, value: T) -> Option<T>[src]

Insert a new value into the AtomicTake and return the previous value.

This function requires unique access to ensure no other threads accesses the AtomicTake concurrently, as this operation cannot be performed atomically without a lock.

Trait Implementations

impl<T> Debug for AtomicTake<T>[src]

impl<T> Drop for AtomicTake<T>[src]

impl<T> From<T> for AtomicTake<T>[src]

impl<T: Send> Sync for AtomicTake<T>[src]

Auto Trait Implementations

impl<T> Send for AtomicTake<T> where
    T: Send

impl<T> Unpin for AtomicTake<T> where
    T: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.