Struct coco::epoch::Atomic
[−]
[src]
pub struct Atomic<T> { /* fields omitted */ }
A tagged atomic nullable pointer.
The tag is stored into the unused least significant bits of the pointer. The pointer must be properly aligned.
Methods
impl<T> Atomic<T>
[src]
fn null(tag: usize) -> Self
Returns a new, null atomic pointer tagged with tag
.
Panics
Panics if the tag doesn't fit into the unused bits of an aligned pointer.
fn new(data: T, tag: usize) -> Self
Allocates data
on the heap and returns a new atomic pointer that points to it and is
tagged with tag
.
Panics
Panics if the tag doesn't fit into the unused bits of the pointer, or if the allocated pointer is unaligned.
fn from_ptr(ptr: Ptr<T>) -> Self
Returns a new atomic pointer initialized with ptr
.
fn from_box(b: Box<T>, tag: usize) -> Self
Returns a new atomic pointer initialized with b
and tag
.
Panics
Panics if the tag doesn't fit into the unused bits of the pointer, or if the pointer is unaligned.
unsafe fn from_raw(raw: *mut T, tag: usize) -> Self
Returns a new atomic pointer initialized with raw
and tag
.
Panics
Panics if the tag doesn't fit into the unused bits of the pointer, or if the pointer is unaligned.
fn load<'p>(&self, _: &'p Pin) -> Ptr<'p, T>
Loads the tagged atomic pointer.
This operation uses the Acquire
ordering.
fn load_raw(&self, order: Ordering) -> (*mut T, usize)
Loads the tagged atomic pointer as a raw pointer and a tag.
Argument order
describes the memory ordering of this operation.
fn store<'p>(&self, new: Ptr<'p, T>)
Stores new
tagged with tag
into the atomic.
This operation uses the Release
ordering.
fn store_box<'p>(&self, new: Box<T>, tag: usize, _: &'p Pin) -> Ptr<'p, T>
Stores new
tagged with tag
into the atomic and returns it.
This operation uses the Release
ordering.
Panics
Panics if the tag doesn't fit into the unused bits of the pointer, or if the pointer is unaligned.
fn store_raw<'p>(
&self,
new: *mut T,
tag: usize,
order: Ordering,
_: &'p Pin
) -> Ptr<'p, T>
&self,
new: *mut T,
tag: usize,
order: Ordering,
_: &'p Pin
) -> Ptr<'p, T>
Stores new
tagged with tag
into the atomic.
Argument order
describes the memory ordering of this operation.
Panics
Panics if the tag doesn't fit into the unused bits of the pointer, or if the pointer is unaligned.
fn swap<'p>(&self, new: Ptr<'p, T>) -> Ptr<'p, T>
Stores new
into the atomic, returning the old tagged pointer.
This operation uses the AcqRel
ordering.
fn swap_box<'p>(&self, new: Box<T>, tag: usize, _: &'p Pin) -> Ptr<'p, T>
Stores new
tagged with tag
into the atomic, returning the old tagged pointer.
This operation uses the AcqRel
ordering.
Panics
Panics if the tag doesn't fit into the unused bits of the pointer, or if the pointer is unaligned.
unsafe fn swap_raw<'p>(
&self,
new: *mut T,
tag: usize,
order: Ordering
) -> Ptr<'p, T>
&self,
new: *mut T,
tag: usize,
order: Ordering
) -> Ptr<'p, T>
Stores new
tagged with tag
into the atomic, returning the old tagged pointer.
Argument order
describes the memory ordering of this operation.
Panics
Panics if the tag doesn't fit into the unused bits of the pointer, or if the pointer is unaligned.
fn cas<'p>(
&self,
current: Ptr<'p, T>,
new: Ptr<'p, T>
) -> Result<(), Ptr<'p, T>>
&self,
current: Ptr<'p, T>,
new: Ptr<'p, T>
) -> Result<(), Ptr<'p, T>>
If the tagged atomic pointer is equal to current
, stores new
.
The return value is a result indicating whether the new pointer was stored. On failure the current value of the tagged atomic pointer is returned.
This operation uses the AcqRel
ordering.
fn cas_box<'p>(
&self,
current: Ptr<'p, T>,
new: Box<T>,
tag: usize
) -> Result<Ptr<'p, T>, (Ptr<'p, T>, Box<T>)>
&self,
current: Ptr<'p, T>,
new: Box<T>,
tag: usize
) -> Result<Ptr<'p, T>, (Ptr<'p, T>, Box<T>)>
If the tagged atomic pointer is equal to current
, stores new
tagged with tag
.
The return value is a result indicating whether the new pointer was stored. On success the
new pointer is returned. On failure the current value of the tagged atomic pointer and
new
are returned.
This operation uses the AcqRel
ordering.
Panics
Panics if the tag doesn't fit into the unused bits of the pointer, or if the pointer is unaligned.
unsafe fn cas_raw(
&self,
current: (*mut T, usize),
new: (*mut T, usize),
order: Ordering
) -> Result<(), (*mut T, usize)>
&self,
current: (*mut T, usize),
new: (*mut T, usize),
order: Ordering
) -> Result<(), (*mut T, usize)>
If the tagged atomic pointer is equal to current
, stores new
.
The return value is a result indicating whether the new pointer was stored. On failure the current value of the tagged atomic pointer is returned.
Argument order
describes the memory ordering of this operation.
Panics
Panics if the tag doesn't fit into the unused bits of the pointer, or if the pointer is unaligned.