[][src]Struct reclaim::Unprotected

pub struct Unprotected<T, R, N> { /* fields omitted */ }

A reference to a value loaded from an Atomic that is not actively protected from reclamation.

Unprotected values can not be safely de-referenced under usual circumstances (i.e. other threads can retire and reclaim unlinked records). They do, however, have stronger guarantees than raw (marked) pointers: Since are loaded from Atomic values they must (at least at one point) have been valid references.

Methods

impl<T, R: Reclaim, N: Unsigned> Unprotected<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(unprotected: 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 unsafe fn deref_unprotected<'a>(self) -> &'a T[src]

Dereferences the Unprotected, returning the resulting reference which is not bound to the lifetime of self.

Safety

Since the pointed-to value is not protected from reclamation it could be freed at any point (even before calling this method). Hence, this method is only safe to call if the caller can guarantee that no reclamation can occur, e.g. when records are never retired at all.

Example

...

pub unsafe fn decompose_ref_unprotected<'a>(self) -> (&'a T, usize)[src]

Decomposes the Unprotected, returning the reference (which is not bound to the lifetime of self) itself and the separated tag.

Safety

Since the pointed-to value is not protected from reclamation it could be freed at any point (even before calling this method). Hence, this method is only safe to call if the caller can guarantee that no reclamation can occur, e.g. when records are never retired at all.

pub unsafe fn into_shared<'a>(unprotected: Self) -> Shared<'a, T, R, N>[src]

Consumes the unprotected and converts it to a Shared reference with arbitrary lifetime.

Safety

The returned reference is not in fact protected and could be reclaimed by other threads, so the caller has to ensure no concurrent reclamation is possible.

pub fn cast<U>(unprotected: Self) -> Unprotected<U, R, N>[src]

Casts the Unprotected to a reference to a different type.

Trait Implementations

impl<T, R: Reclaim, N: Unsigned> MarkedPointer for Unprotected<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.

impl<T, R, N: Unsigned> NonNullable for Unprotected<T, R, N>[src]

type Item = T

The pointed-to type.

type MarkBits = N

Number of bits available for tagging.

impl<T: PartialOrd, R: PartialOrd, N: PartialOrd> PartialOrd<Unprotected<T, R, N>> for Unprotected<T, R, N>[src]

impl<T: PartialEq, R: PartialEq, N: PartialEq> PartialEq<Unprotected<T, R, N>> for Unprotected<T, R, N>[src]

impl<T, R: Reclaim, N> Copy for Unprotected<T, R, N>[src]

impl<T: Ord, R: Ord, N: Ord> Ord for Unprotected<T, R, N>[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

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

Restrict a value to a certain interval. Read more

impl<T: Eq, R: Eq, N: Eq> Eq for Unprotected<T, R, N>[src]

impl<T, R, N> Clone for Unprotected<T, R, N>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T, R: Reclaim, N: Unsigned> Debug for Unprotected<T, R, N>[src]

impl<T, R: Reclaim, N: Unsigned> Pointer for Unprotected<T, R, N>[src]

Auto Trait Implementations

impl<T, R, N> !Send for Unprotected<T, R, N>

impl<T, R, N> Unpin for Unprotected<T, R, N> where
    N: Unpin,
    R: Unpin,
    T: Unpin

impl<T, R, N> !Sync for Unprotected<T, R, N>

impl<T, R, N> UnwindSafe for Unprotected<T, R, N> where
    N: UnwindSafe,
    R: UnwindSafe,
    T: RefUnwindSafe

impl<T, R, N> RefUnwindSafe for Unprotected<T, R, N> where
    N: RefUnwindSafe,
    R: RefUnwindSafe,
    T: RefUnwindSafe

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self