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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Do cleanup on this data, potentially leaving it in an invalid state. (See trait documentation for the rules for implementing this method.) Read more

scan should use the scanner to scan all of its directly owned data

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.