#[repr(C)]
pub(crate) struct Local { entry: Entry, collector: UnsafeCell<ManuallyDrop<Collector>>, pub(crate) bag: UnsafeCell<Bag>, guard_count: Cell<usize>, handle_count: Cell<usize>, pin_count: Cell<Wrapping<usize>>, epoch: CachePadded<AtomicEpoch>, }
Expand description

Participant for garbage collection.

Fields§

§entry: Entry

A node in the intrusive linked list of Locals.

§collector: UnsafeCell<ManuallyDrop<Collector>>

A reference to the global data.

When all guards and handles get dropped, this reference is destroyed.

§bag: UnsafeCell<Bag>

The local bag of deferred functions.

§guard_count: Cell<usize>

The number of guards keeping this participant pinned.

§handle_count: Cell<usize>

The number of active handles.

§pin_count: Cell<Wrapping<usize>>

Total number of pinnings performed.

This is just an auxiliary counter that sometimes kicks off collection.

§epoch: CachePadded<AtomicEpoch>

The local epoch.

Implementations§

source§

impl Local

source

const PINNINGS_BETWEEN_COLLECT: usize = 128usize

Number of pinnings after which a participant will execute some deferred functions from the global queue.

source

pub(crate) fn register(collector: &Collector) -> LocalHandle

Registers a new Local in the provided Global.

source

pub(crate) fn global(&self) -> &Global

Returns a reference to the Global in which this Local resides.

source

pub(crate) fn collector(&self) -> &Collector

Returns a reference to the Collector in which this Local resides.

source

pub(crate) fn is_pinned(&self) -> bool

Returns true if the current participant is pinned.

source

pub(crate) unsafe fn defer(&self, deferred: Deferred, guard: &Guard)

Adds deferred to the thread-local bag.

Safety

It should be safe for another thread to execute the given function.

source

pub(crate) fn flush(&self, guard: &Guard)

source

pub(crate) fn pin(&self) -> Guard

Pins the Local.

source

pub(crate) fn unpin(&self)

Unpins the Local.

source

pub(crate) fn repin(&self)

Unpins and then pins the Local.

source

pub(crate) fn acquire_handle(&self)

Increments the handle count.

source

pub(crate) fn release_handle(&self)

Decrements the handle count.

source

fn finalize(&self)

Removes the Local from the global linked list.

Trait Implementations§

source§

impl IsElement<Local> for Local

source§

fn entry_of(local: &Self) -> &Entry

Returns a reference to this element’s Entry.
source§

unsafe fn element_of(entry: &Entry) -> &Self

Given a reference to an element’s entry, returns that element. Read more
source§

unsafe fn finalize(entry: &Entry, guard: &Guard)

The function that is called when an entry is unlinked from list. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Local

§

impl Send for Local

§

impl !Sync for Local

§

impl Unpin for Local

§

impl !UnwindSafe for Local

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 = const ALIGN: usize = mem::align_of::<T>();

The alignment of pointer.
§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.