Struct shredder::atomic::AtomicGc [−][src]
pub struct AtomicGc<T: Scan> { /* fields omitted */ }
Expand description
An atomic Gc<T>
, useful for concurrent algorithms
This has more overhead than an AtomicPtr
, but cleanly handles memory management. It also is
similar to Gc<T>
in that it can be cloned, and therefore easily shared.
A good analogy would be to the excellent arc-swap
crate. However, we can be more performant,
as relying on the collector lets us avoid some synchronization.
AtomicGc
should be fairly fast, but you may not assume it does not block. In fact in the
presence of an active garbage collection operation, all operations will block. Otherwise
it shouldn’t block.
Implementations
Create a new AtomicGc
The created AtomicGc
will point to the same data as data
load
the data from this AtomicGc<T>
, getting back a Gc<T>
The ordering/atomicity guarantees are identical to AtomicPtr::load
store
new data into this AtomicGc
The ordering/atomicity guarantees are identical to AtomicPtr::store
swap
what data is stored in this AtomicGc
, getting a Gc
to the old data back
The ordering/atomicity guarantees are identical to AtomicPtr::swap
Do a CAS operation. If this AtomicGc
points to the same data as current
then after this
operation it will point to the same data as new
. (And this happens atomically.)
Data is compared for pointer equality. NOT Eq
equality. (A swap will only happen if
current
and this AtomicGc
point to the same underlying allocation.)
The ordering/atomicity guarantees are identical to AtomicPtr::compare_and_swap
Returns
Returns true
if the swap happened and this AtomicGc
now points to new
Returns false
if the swap failed / this AtomicGc
was not pointing to current
Do a CAE operation. If this AtomicGc
points to the same data as current
then after this
operation it will point to the same data as new
. (And this happens atomically.)
Data is compared for pointer equality. NOT Eq
equality. (A swap will only happen if
current
and this AtomicGc
point to the same underlying allocation.)
The ordering/atomicity guarantees are identical to AtomicPtr::compare_exchange
, refer to
that documentation for documentation about success
and failure
orderings.
Returns
Returns true
if the swap happened and this AtomicGc
now points to new
Returns false
if the swap failed / this AtomicGc
was not pointing to current
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for AtomicGc<T>
impl<T> !UnwindSafe for AtomicGc<T>
Blanket Implementations
Mutably borrows from an owned value. Read more