Skip to main content

AtomicFlags

Struct AtomicFlags 

Source
pub struct AtomicFlags<F>
where F: Flags + Copy, F::Bits: AtomicBits,
{ /* private fields */ }
Expand description

A flag set stored in an atomic integer.

Implementations§

Source§

impl<F> AtomicFlags<F>
where F: Flags + Copy, F::Bits: AtomicBits,

Source

pub fn new(flags: F) -> Self

Source

pub fn store(&self, flags: F, ordering: Ordering)

Source

pub fn load(&self, ordering: Ordering) -> F

Source

pub fn fetch_and(&self, flags: F, ordering: Ordering) -> F

Atomically clears flags, returning the previous value.

Source

pub fn fetch_or(&self, flags: F, ordering: Ordering) -> F

Atomically sets flags, returning the previous value.

Source

pub fn fetch_xor(&self, flags: F, ordering: Ordering) -> F

Atomically toggles flags, returning the previous value.

Source

pub fn fetch_nand(&self, flags: F, ordering: Ordering) -> F

Atomically replaces the value with !(current & flags), returning the previous value.

This follows the standard atomic fetch_nand: the result is not restricted to flags, so bits outside the mask are set.

Source

pub fn swap(&self, flags: F, ordering: Ordering) -> F

Atomically replaces the value with flags, returning the previous value.

Source

pub fn take(&self, flags: F, ordering: Ordering) -> F

Atomically clears flags and returns the subset that was set.

Returns an empty set if none of flags were set. Other bits are left untouched.

Source

pub fn peek(&self, flags: F, ordering: Ordering) -> F

Returns the subset of flags that is currently set.

Does not modify the stored value. The result is a snapshot from a single load; use take to claim flags atomically.

Source

pub fn clear(&self, ordering: Ordering)

Clears all flags.

Source

pub fn into_inner(self) -> F

Consumes the atomic and returns the flags.

Source

pub fn set(&self, flags: F, ordering: Ordering) -> F

Atomically sets the bits in flags, returning the previous value.

Source

pub fn unset(&self, flags: F, ordering: Ordering) -> F

Atomically clears the bits in flags, returning the previous value.

Trait Implementations§

Source§

impl<F> Debug for AtomicFlags<F>
where F: Flags + Copy + Debug, F::Bits: AtomicBits,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F> Default for AtomicFlags<F>
where F: Flags + Copy + Default, F::Bits: AtomicBits,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<F> Freeze for AtomicFlags<F>
where <F as Flags>::Bits: Sized, <<F as Flags>::Bits as AtomicBits>::Storage: Freeze,

§

impl<F> RefUnwindSafe for AtomicFlags<F>
where <F as Flags>::Bits: Sized, <<F as Flags>::Bits as AtomicBits>::Storage: RefUnwindSafe,

§

impl<F> Send for AtomicFlags<F>
where <F as Flags>::Bits: Sized, <<F as Flags>::Bits as AtomicBits>::Storage: Send,

§

impl<F> Sync for AtomicFlags<F>
where <F as Flags>::Bits: Sized, <<F as Flags>::Bits as AtomicBits>::Storage: Sync,

§

impl<F> Unpin for AtomicFlags<F>
where <F as Flags>::Bits: Sized, <<F as Flags>::Bits as AtomicBits>::Storage: Unpin,

§

impl<F> UnsafeUnpin for AtomicFlags<F>
where <F as Flags>::Bits: Sized, <<F as Flags>::Bits as AtomicBits>::Storage: UnsafeUnpin,

§

impl<F> UnwindSafe for AtomicFlags<F>
where <F as Flags>::Bits: Sized, <<F as Flags>::Bits as AtomicBits>::Storage: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.