Skip to main content

Value

Trait Value 

Source
pub trait Value: Value + Borrow<Self::Borrowed> {
    type Borrowed;
    type Guard<G>: Guard<Self> + From<G>
       where G: Guard<Self>;

    const INDIRECT: bool;

    // Required method
    unsafe fn borrow_from_raw_unchecked(raw: &u64) -> &Self::Borrowed;
}
Expand description

Values that can safely be stored in a ConcurrentMap.

Values may be either inline or indirect. An inline value (e.g., u64) is stored directly in an edge and can be freely copied. An indirect value (e.g., Box<T>) is a pointer to a separate allocation; the pointer is stored in an edge.

Note: we don’t need Send or Sync bounds here. It’s fine to create a concurrent map with non-Sync values; the map instance just won’t implement Sync.

Required Associated Constants§

Source

const INDIRECT: bool

Whether this is an indirect value (otherwise it is inline).

Required Associated Types§

Source

type Borrowed

We need this extra layer of indirection relative to SequentialMap because edges can be concurrently modified.

For an inline value, the sequential map can return a reference to the edge containing the value; the borrow checker ensures the edge is immutable. This is not true for the concurrent map, which instead needs to copy out the value and return a reference to the copy.

For an indirect value, the concurrent map copies out a pointer and interprets it as reference.

Source

type Guard<G>: Guard<Self> + From<G> where G: Guard<Self>

This is a type-level function that allows inline values to discard a smr::Guard.

Required Methods§

Source

unsafe fn borrow_from_raw_unchecked(raw: &u64) -> &Self::Borrowed

§Safety

Caller must guarantee the following:

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Value for i64

Source§

const INDIRECT: bool = false

Source§

type Borrowed = i64

Source§

type Guard<G> = Guard<G, i64> where G: Guard<Self>

Source§

unsafe fn borrow_from_raw_unchecked(raw: &u64) -> &Self::Borrowed

Source§

impl Value for u64

Source§

const INDIRECT: bool = false

Source§

type Borrowed = u64

Source§

type Guard<G> = Guard<G, u64> where G: Guard<Self>

Source§

unsafe fn borrow_from_raw_unchecked(raw: &u64) -> &Self::Borrowed

Source§

impl<'v, T: 'v + Sized> Value for &'v T

Source§

const INDIRECT: bool = false

Source§

type Borrowed = &'v T

Source§

type Guard<G> = Guard<G, &'v T> where G: Guard<Self>

Source§

unsafe fn borrow_from_raw_unchecked(raw: &u64) -> &Self::Borrowed

Source§

impl<T: Sized> Value for Box<T>

Source§

const INDIRECT: bool = true

Source§

type Borrowed = T

Source§

type Guard<G> = G where G: Guard<Self>

Source§

unsafe fn borrow_from_raw_unchecked(raw: &u64) -> &Self::Borrowed

Implementors§

Source§

impl<T: Sized> Value for Arc<T>

Source§

const INDIRECT: bool = true

Source§

type Borrowed = ArcRef<T>

Source§

type Guard<G> = G where G: Guard<Self>