[−][src]Trait reclaim::Protect
A trait for guard types that protect a specific value from reclamation during the lifetime of the protecting guard.
Examples
use core::sync::atomic::Ordering::Relaxed; use reclaim::typenum::U0; use reclaim::prelude::*; // `Leaking` implements both `Protect` and `ProtectRegion` use reclaim::leak::Guard; type Atomic<T> = reclaim::leak::Atomic<T, U0>; let atomic = Atomic::new(1); let mut guard = Guard::new(); let shared = atomic.load(Relaxed, &mut guard).unwrap(); assert_eq!(&*shared, &1);
Associated Types
Loading content...Required methods
fn release(&mut self)
Releases any current protection that may be provided by the guard.
By borrowing self
mutably it is ensured that no loaded values
protected by this guard can be used after calling this method.
If Self
additionally implements ProtectRegion
, this is a no-op
fn protect<T, N: Unsigned>(
&mut self,
atomic: &Atomic<T, Self::Reclaimer, N>,
order: Ordering
) -> Marked<Shared<T, Self::Reclaimer, N>>
&mut self,
atomic: &Atomic<T, Self::Reclaimer, N>,
order: Ordering
) -> Marked<Shared<T, Self::Reclaimer, N>>
Atomically takes a snapshot of atomic
and returns a protected
Shared
reference wrapped in a Marked
to it.
The loaded value is stored within self
. If the value of atomic
is
null
or a pure tag (marked null
pointer), no protection has to be
established. Any previously protected value will be overwritten and be
no longer protected, regardless of the loaded value.
Panics
fn protect_if_equal<T, N: Unsigned>(
&mut self,
atomic: &Atomic<T, Self::Reclaimer, N>,
expected: MarkedPtr<T, N>,
order: Ordering
) -> AcquireResult<T, Self::Reclaimer, N>
&mut self,
atomic: &Atomic<T, Self::Reclaimer, N>,
expected: MarkedPtr<T, N>,
order: Ordering
) -> AcquireResult<T, Self::Reclaimer, N>
Atomically takes a snapshot of atomic
and returns a protected
Shared
reference wrapped in a Marked
to it, if the loaded
value is equal to expected
.
A successfully loaded value is stored within self
. If the value of
atomic
is null
or a pure tag (marked null
pointer), no protection
has to be established. After a successful load, any previously
protected value will be overwritten and be no longer protected,
regardless of the loaded value. In case of a unsuccessful load, the
previously protected value does not change.
Errors
This method returns an Err(NotEqualError)
result, if
the atomically loaded snapshot from atomic
does not match the
expected
value.
Panics
Provided methods
fn try_fuse<T, N: Unsigned>(
self,
atomic: &Atomic<T, Self::Reclaimer, N>,
order: Ordering
) -> Result<Guarded<T, Self, N>, Self>
self,
atomic: &Atomic<T, Self::Reclaimer, N>,
order: Ordering
) -> Result<Guarded<T, Self, N>, Self>
Implementors
impl Protect for Guard
[src]
type Reclaimer = Leaking
fn release(&mut self)
[src]
This is a no-op.
fn protect<T, N: Unsigned>(
&mut self,
atomic: &Atomic<T, N>,
order: Ordering
) -> Marked<Shared<T, N>>
[src]
&mut self,
atomic: &Atomic<T, N>,
order: Ordering
) -> Marked<Shared<T, N>>
Acquires a value from shared memory.
fn protect_if_equal<T, N: Unsigned>(
&mut self,
atomic: &Atomic<T, N>,
expected: MarkedPtr<T, N>,
order: Ordering
) -> AcquireResult<T, Self::Reclaimer, N>
[src]
&mut self,
atomic: &Atomic<T, N>,
expected: MarkedPtr<T, N>,
order: Ordering
) -> AcquireResult<T, Self::Reclaimer, N>
Acquires a value from shared memory if it equals expected
.