pub struct PotentialAtomicOption<T, W: PotentialWell>(/* private fields */);Expand description
Type-hoisted AtomicOption.
Uses PotentialWell to allow for recursive structures at the cost of some usability.
See the documentation for PotentialWell for more information.
Implementations§
Source§impl<T, W: PotentialWell> PotentialAtomicOption<T, W>
impl<T, W: PotentialWell> PotentialAtomicOption<T, W>
Sourcepub fn none() -> PotentialAtomicOption<T, W>
pub fn none() -> PotentialAtomicOption<T, W>
Creates atomic without anything inside.
Sourcepub fn some(well: KineticWell<T, W>) -> PotentialAtomicOption<T, W>
pub fn some(well: KineticWell<T, W>) -> PotentialAtomicOption<T, W>
Creates atomic with something inside.
Sourcepub fn new(well: Option<KineticWell<T, W>>) -> PotentialAtomicOption<T, W>
pub fn new(well: Option<KineticWell<T, W>>) -> PotentialAtomicOption<T, W>
Creates atomic.
Sourcepub unsafe fn as_raw_unchecked(&self) -> &AtomicPtr<T>
pub unsafe fn as_raw_unchecked(&self) -> &AtomicPtr<T>
Gives access to the underlying AtomicPtr.
§Safety
The pointer inside the atomic must always be null, or a valid pointer from Well::remove.
Additionally, keep in mind that this atomic owns the pointer, and if you want to move it
out, you must put a different pointer in its place first.
Sourcepub fn swap(
&self,
well: KineticWell<T, W>,
ordering: Ordering,
) -> Option<KineticWell<T, W>>
pub fn swap( &self, well: KineticWell<T, W>, ordering: Ordering, ) -> Option<KineticWell<T, W>>
Atomically swaps the data inside the well.
This is equivalent to an atomic swap.
Sourcepub fn take(&self, ordering: Ordering) -> Option<KineticWell<T, W>>
pub fn take(&self, ordering: Ordering) -> Option<KineticWell<T, W>>
Takes the data out of the well.
This is equivalent to an atomic swap with a null pointer.
Sourcepub fn insert(
&self,
well: KineticWell<T, W>,
success: Ordering,
failure: Ordering,
) -> Result<(), KineticWell<T, W>>
pub fn insert( &self, well: KineticWell<T, W>, success: Ordering, failure: Ordering, ) -> Result<(), KineticWell<T, W>>
Inserts data into the well.
This uses compare_exchange to avoid inserting into the well if it’s already full. If you
want to use compare_exchange_weak instead, use insert_weak.
Sourcepub fn insert_weak(
&self,
well: KineticWell<T, W>,
success: Ordering,
failure: Ordering,
) -> Result<(), KineticWell<T, W>>
pub fn insert_weak( &self, well: KineticWell<T, W>, success: Ordering, failure: Ordering, ) -> Result<(), KineticWell<T, W>>
Inserts data into the well, sometimes failing spuriously.
This uses compare_exchange_weak to avoid inserting into the well if it’s already full,
which may spuriously fail. If you want to use compare_exchange instead, use insert.
Source§impl<T, W: PotentialWell> PotentialAtomicOption<T, W>
impl<T, W: PotentialWell> PotentialAtomicOption<T, W>
Sourcepub fn load(&self, ordering: Ordering) -> Option<&T>
pub fn load(&self, ordering: Ordering) -> Option<&T>
Loads the inner data as an immutable reference.
This is equivalent to an atomic load.
Sourcepub fn swap_get(
&self,
well: KineticWell<T, W>,
ordering: Ordering,
) -> (Option<KineticWell<T, W>>, &T)
pub fn swap_get( &self, well: KineticWell<T, W>, ordering: Ordering, ) -> (Option<KineticWell<T, W>>, &T)
Atomically swaps the data inside the well and returns a reference to the new data.
This is swap, but with the unsafe deref hidden behind a safe API.
Sourcepub fn insert_get(
&self,
well: KineticWell<T, W>,
success: Ordering,
failure: Ordering,
) -> Result<&T, KineticWell<T, W>>
pub fn insert_get( &self, well: KineticWell<T, W>, success: Ordering, failure: Ordering, ) -> Result<&T, KineticWell<T, W>>
Inserts data into the well and returns a reference to the new data.
This is insert, but with the unsafe deref hidden behind a safe API.
Sourcepub fn insert_weak_get(
&self,
well: KineticWell<T, W>,
success: Ordering,
failure: Ordering,
) -> Result<&T, KineticWell<T, W>>
pub fn insert_weak_get( &self, well: KineticWell<T, W>, success: Ordering, failure: Ordering, ) -> Result<&T, KineticWell<T, W>>
Inserts data into the well, returns reference to the new data, sometimes failing spuriously.
This is insert_weak, but with the unsafe deref hidden behind a safe API.
Source§impl<T: Unpin, W: PotentialWell> PotentialAtomicOption<T, W>
impl<T: Unpin, W: PotentialWell> PotentialAtomicOption<T, W>
Source§impl<T, W: PotentialWell> PotentialAtomicOption<T, Pin<W>>where
KineticWell<T, W>: StrongWellMut + Deref<Target = T>,
Pin<W>: PotentialWell<Well<T> = Pin<KineticWell<T, W>>>,
impl<T, W: PotentialWell> PotentialAtomicOption<T, Pin<W>>where
KineticWell<T, W>: StrongWellMut + Deref<Target = T>,
Pin<W>: PotentialWell<Well<T> = Pin<KineticWell<T, W>>>,
Source§impl<T, W: PotentialWell> PotentialAtomicOption<T, W>where
KineticWell<T, W>: Clone,
impl<T, W: PotentialWell> PotentialAtomicOption<T, W>where
KineticWell<T, W>: Clone,
Sourcepub fn load_clone(&self, ordering: Ordering) -> Option<KineticWell<T, W>>
pub fn load_clone(&self, ordering: Ordering) -> Option<KineticWell<T, W>>
Loads a clone of the inner data.
This still performs an atomic load, but instead of offering a reference, the smart
pointer is cloned instead.
Trait Implementations§
Source§impl<T, W: PotentialWell> Debug for PotentialAtomicOption<T, W>where
KineticWell<T, W>: Debug,
impl<T, W: PotentialWell> Debug for PotentialAtomicOption<T, W>where
KineticWell<T, W>: Debug,
Source§impl<T, W: PotentialWell> Default for PotentialAtomicOption<T, W>
By default, nothing is stored in the atomic.
impl<T, W: PotentialWell> Default for PotentialAtomicOption<T, W>
By default, nothing is stored in the atomic.