[−][src]Struct reclaim::Unprotected
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.
fn as_marked_ptr(&self) -> MarkedPtr<T, N>
[src]
fn into_marked_ptr(self) -> MarkedPtr<Self::Item, Self::MarkBits>
[src]
fn marked(unprotected: Self, tag: usize) -> Marked<Self::Pointer>
[src]
fn unmarked(unprotected: Self) -> Self
[src]
fn decompose(unprotected: 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 Unprotected<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: PartialOrd, R: PartialOrd, N: PartialOrd> PartialOrd<Unprotected<T, R, N>> for Unprotected<T, R, N>
[src]
fn partial_cmp(&self, other: &Unprotected<T, R, N>) -> Option<Ordering>
[src]
fn lt(&self, other: &Unprotected<T, R, N>) -> bool
[src]
fn le(&self, other: &Unprotected<T, R, N>) -> bool
[src]
fn gt(&self, other: &Unprotected<T, R, N>) -> bool
[src]
fn ge(&self, other: &Unprotected<T, R, N>) -> bool
[src]
impl<T: PartialEq, R: PartialEq, N: PartialEq> PartialEq<Unprotected<T, R, N>> for Unprotected<T, R, N>
[src]
fn eq(&self, other: &Unprotected<T, R, N>) -> bool
[src]
fn ne(&self, other: &Unprotected<T, R, N>) -> bool
[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 cmp(&self, other: &Unprotected<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: 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(&self) -> Self
[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,
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,
N: UnwindSafe,
R: UnwindSafe,
T: RefUnwindSafe,
impl<T, R, N> RefUnwindSafe for Unprotected<T, R, N> where
N: RefUnwindSafe,
R: RefUnwindSafe,
T: RefUnwindSafe,
N: RefUnwindSafe,
R: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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