[−][src]Struct reclaim::Unlinked
A reference to a value that has been removed from its previous location in memory and is hence no longer reachable by other threads.
Unlinked
values are the result of (successful) atomic swap or
compare-and-swap operations on Atomic
values.
They are move-only types, but they don't have full ownership semantics,
either.
Dropping an Unlinked
value without explicitly retiring it almost certainly
results in a memory leak.
The safety invariants around retiring Unlinked
references are explained
in detail in the documentation for retire_local
.
Methods
impl<T, R: Reclaim, N: Unsigned> Unlinked<T, R, N>
[src]
pub fn none() -> Option<Self>
[src]
Creates a None
variant for an Option<Self>
.
This is useful for calls to store
, swap
or
compare_exchange_*
, when a null
pointer
needs to be inserted.
These methods accept values of various non-nullable pointer types
(Shared
, Owned
, Unlinked
and
Unprotected
) and Option
types thereof as
argument.
However, the compiler is usually not able to infer the concrete
type, when a None
is inserted, and this function is intended for
these cases.
Example
use std::sync::atomic::Ordering; type Atomic<T> = reclaim::leak::Atomic<T, reclaim::typenum::U0>; type Owned<T> = reclaim::leak::Owned<T, reclaim::typenum::U0>; type Unlinked<T> = reclaim::leak::Unlinked<T, reclaim::typenum::U0>; let atomic = Atomic::new(1); let swap = atomic.swap(Owned::none(), Ordering::Relaxed).unwrap(); assert_eq!(swap.as_ref(), &1); unsafe { Unlinked::retire(swap) }; // leaks memory
pub fn null() -> Marked<Self>
[src]
Creates an unmarked Null
variant
for a Marked<Self>
.
pub fn null_with_tag(tag: usize) -> Marked<Self>
[src]
Creates a marked Null
variant for
a Marked<Self>
with the given tag
.
pub fn compose(unlinked: Self, tag: usize) -> Self
[src]
Consumes the given Self
and returns the same value but with the
specified tag
.
Any previous tag is overwritten.
pub fn decompose_ref(unlinked: &Self) -> (&T, usize)
[src]
Decomposes the marked reference, returning the reference itself and the separated tag.
pub fn into_unprotected(shared: Self) -> Unprotected<T, R, N>
[src]
Converts the Unlinked
reference into an Unprotected
.
pub unsafe fn cast<U>(unlinked: Self) -> Unlinked<U, R, N>
[src]
Casts the Unlinked
to a reference to a different type.
Safety
The caller has to ensure the cast is valid.
pub unsafe fn retire_local(self, local: &R::Local) where
T: 'static,
[src]
T: 'static,
Retires a record by calling retire_local
on the generic
reclamation parameter R
.
Safety
The same caveats as with LocalReclaim::retire_local
apply.
Note
This method takes self
as receiver, which means it may conflict with
methods of T
, since Unlinked
implements Deref
.
This is a deliberate trade-off in favor of better ergonomics around
retiring records.
pub unsafe fn retire_local_unchecked(self, local: &R::Local)
[src]
Retires a record by calling retire_local_unchecked
on the generic reclamation parameter R
.
Safety
The same caveats as with LocalReclaim::retire_local_unchecked
apply.
Note
This method takes self
as receiver, which means it may conflict with
methods of T
, since Unlinked
implements Deref
.
This is a deliberate trade-off in favor of better ergonomics around
retiring records.
impl<T, R: GlobalReclaim, N: Unsigned> Unlinked<T, R, N>
[src]
pub unsafe fn retire(self) where
T: 'static,
[src]
T: 'static,
Retires a record by calling retire
on the generic
reclamation parameter R
.
Safety
The same caveats as with Reclaim::retire
apply.
Note
This method takes self
as receiver, which means it may conflict with
methods of T
, since Unlinked
implements Deref
.
This is a deliberate trade-off in favor of better ergonomics around
retiring records.
pub unsafe fn retire_unchecked(self)
[src]
Retires a record by calling retire_unchecked
on
the generic reclamation parameter R
.
Safety
The same caveats as with Reclaim::retire_unchecked
apply.
Note
This method takes self
as receiver, which means it may conflict with
methods of T
, since Unlinked
implements Deref
.
This is a deliberate trade-off in favor of better ergonomics around
retiring records.
Trait Implementations
impl<T, R: Reclaim, N: Unsigned> MarkedPointer for Unlinked<T, R, N>
[src]
type Pointer = Self
The pointer type.
type Item = T
The pointed-to type.
type MarkBits = N
Number of bits available for tagging.
fn as_marked_ptr(&self) -> MarkedPtr<T, N>
[src]
fn into_marked_ptr(self) -> MarkedPtr<Self::Item, Self::MarkBits>
[src]
fn marked(unlinked: Self, tag: usize) -> Marked<Self::Pointer>
[src]
fn unmarked(unlinked: Self) -> Self
[src]
fn decompose(unlinked: Self) -> (Self, usize)
[src]
unsafe fn from_marked_ptr(marked: MarkedPtr<Self::Item, Self::MarkBits>) -> Self
[src]
unsafe fn from_marked_non_null(
marked: MarkedNonNull<Self::Item, Self::MarkBits>
) -> Self
[src]
marked: MarkedNonNull<Self::Item, Self::MarkBits>
) -> Self
impl<T, R, N: Unsigned> NonNullable for Unlinked<T, R, N>
[src]
type Item = T
The pointed-to type.
type MarkBits = N
Number of bits available for tagging.
fn into_marked_non_null(self) -> MarkedNonNull<Self::Item, Self::MarkBits>
[src]
impl<T: PartialEq, R: PartialEq, N: PartialEq> PartialEq<Unlinked<T, R, N>> for Unlinked<T, R, N>
[src]
fn eq(&self, other: &Unlinked<T, R, N>) -> bool
[src]
fn ne(&self, other: &Unlinked<T, R, N>) -> bool
[src]
impl<T, R: Reclaim, N: Unsigned> AsRef<T> for Unlinked<T, R, N>
[src]
impl<T: PartialOrd, R: PartialOrd, N: PartialOrd> PartialOrd<Unlinked<T, R, N>> for Unlinked<T, R, N>
[src]
fn partial_cmp(&self, other: &Unlinked<T, R, N>) -> Option<Ordering>
[src]
fn lt(&self, other: &Unlinked<T, R, N>) -> bool
[src]
fn le(&self, other: &Unlinked<T, R, N>) -> bool
[src]
fn gt(&self, other: &Unlinked<T, R, N>) -> bool
[src]
fn ge(&self, other: &Unlinked<T, R, N>) -> bool
[src]
impl<T: Eq, R: Eq, N: Eq> Eq for Unlinked<T, R, N>
[src]
impl<T: Ord, R: Ord, N: Ord> Ord for Unlinked<T, R, N>
[src]
fn cmp(&self, other: &Unlinked<T, R, N>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl<T, R: Reclaim, N: Unsigned> Debug for Unlinked<T, R, N>
[src]
impl<T, R: Reclaim, N: Unsigned> Deref for Unlinked<T, R, N>
[src]
impl<T, R: Reclaim, N: Unsigned> Pointer for Unlinked<T, R, N>
[src]
Auto Trait Implementations
impl<T, R, N> !Send for Unlinked<T, R, N>
impl<T, R, N> Unpin for Unlinked<T, R, N> where
N: Unpin,
R: Unpin,
T: Unpin,
N: Unpin,
R: Unpin,
T: Unpin,
impl<T, R, N> !Sync for Unlinked<T, R, N>
impl<T, R, N> RefUnwindSafe for Unlinked<T, R, N> where
N: RefUnwindSafe,
R: RefUnwindSafe,
T: RefUnwindSafe,
N: RefUnwindSafe,
R: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, R, N> UnwindSafe for Unlinked<T, R, N> where
N: UnwindSafe,
R: UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
N: UnwindSafe,
R: UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self