Union Segment

Source
union Segment<T> {
    children: ManuallyDrop<[Atomic<Segment<T>>; 1024]>,
    elements: ManuallyDrop<[Atomic<T>; 1024]>,
}
Expand description

A fixed size array of atomic pointers to other Segment<T> or T.

Each segment is either an inner segment with pointers to other, children Segment<T> or an element segment with pointers to T. This is determined by the height of this segment in the main array, which one needs to track separately. For example, use the main array root’s tag.

Since destructing segments requires its height information, it is not recommended to implement Drop. Rather, implement and use the custom Segment::deallocate method that accounts for the height of the segment.

Fields§

§children: ManuallyDrop<[Atomic<Segment<T>>; 1024]>§elements: ManuallyDrop<[Atomic<T>; 1024]>

Implementations§

Source§

impl<T> Segment<T>

Source

fn new() -> Owned<Self>

Create a new segment filled with null pointers. It is up to the callee to whether to use this as an intermediate or an element segment.

Source

unsafe fn deallocate(self, height: usize)

Deallocates a segment of height.

§Safety
  • self must actually have height height.
  • There should be no other references to possible children segments.

Trait Implementations§

Source§

impl<T> Debug for Segment<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for Segment<T>

§

impl<T> RefUnwindSafe for Segment<T>
where T: RefUnwindSafe,

§

impl<T> Send for Segment<T>
where T: Send + Sync,

§

impl<T> Sync for Segment<T>
where T: Send + Sync,

§

impl<T> Unpin for Segment<T>

§

impl<T> UnwindSafe for Segment<T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V