[−][src]Trait reclaim::GlobalReclaim
A trait for retiring and reclaiming entries removed from concurrent collections and data structures.
Implementing this trait requires first implementing the Reclaim
trait for the same type and is usually only possible in std
environments
with access to thread local storage.
Examples
Defining a concurrent data structure generic over the employed reclamation scheme:
use reclaim::typenum::U0; use reclaim::GlobalReclaim; type Atomic<T, R> = reclaim::Atomic<T, R, U0>; pub struct Stack<T, R: GlobalReclaim> { head: Atomic<Node<T, R>, R>, } struct Node<T, R: GlobalReclaim> { elem: T, next: Atomic<Node<T, R>, R>, }
Associated Types
type Guard: Protect<Reclaimer = Self> + Default
The type used for protecting concurrently shared references.
Required methods
fn try_flush()
Attempts to safely reclaim some retired records.
Retired records are often cached locally by each thread to some extent. In cases, where opportunities for reclaiming these records (usually actions requiring protection of shared values) materialize only rarely, this function can be used to initiate the (safe) reclamation manually.
unsafe fn retire<T: 'static, N: Unsigned>(unlinked: Unlinked<T, Self, N>)
Retires a record and caches it at least until it is safe to deallocate it.
For further information, refer to the documentation of
retire_local
.
Safety
The same caveats as with [retire_local
][LocalReclaim::retire_local
]
apply.
unsafe fn retire_unchecked<T, N: Unsigned>(unlinked: Unlinked<T, Self, N>)
Retires a record and caches it at least until it is safe to deallocate it.
For further information, refer to the documentation of
retire_local_unchecked
.
Safety
The same caveats as with retire_local
apply.
Provided methods
fn guard() -> Self::Guard
Creates a new Guard
.
When Self::Guard
implements ProtectRegion
, this operation
instantly establishes protection for loaded values.
Otherwise, the guard must first explicitly protect a specific shared
value.
unsafe fn retire_raw<T, N: Unsigned>(ptr: MarkedPtr<T, N>)
Retires a raw marked pointer to a record.
Safety
The same caveats as with retire_local_raw
apply.
Panics
In debug mode, this function panics if ptr
is null
.