[−][src]Struct atomic_take::AtomicTake
A container with an atomic take operation.
Methods
impl<T> AtomicTake<T>
[src]
pub fn new(value: T) -> Self
[src]
Create a new AtomicTake
with the given 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 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
Auto Trait Implementations
impl<T> Unpin for AtomicTake<T> where
T: Unpin,
T: Unpin,
impl<T> Send for AtomicTake<T> where
T: Send,
T: Send,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,