PinGuard

Struct PinGuard 

Source
pub struct PinGuard<'a> { /* private fields */ }
Expand description

A guard that keeps the current thread pinned to an epoch.

PinGuard is obtained by calling LocalEpoch::pin(). It is !Send and !Sync because it references a !Sync LocalEpoch. Its lifetime is bound to the LocalEpoch it came from.

While a PinGuard is held, the thread is considered “active” at a particular epoch, and the garbage collector will not reclaim data from that epoch.

PinGuard supports internal cloning via reference counting (increments the pin count), allowing nested pinning. The thread remains pinned until all cloned guards are dropped.

Safety: The PinGuard is the mechanism that ensures safe concurrent access to EpochPtr values. Readers must always hold a valid PinGuard when accessing shared data through EpochPtr::load().

一个保持当前线程被钉住到一个纪元的守卫。 PinGuard 通过调用 LocalEpoch::pin() 获得。 它是 !Send!Sync 的,因为它引用了一个 !SyncLocalEpoch。 它的生命周期被绑定到它来自的 LocalEpoch。 当 PinGuard 被持有时,线程被认为在特定纪元“活跃“, 垃圾回收器不会回收该纪元的数据。 PinGuard 支持通过引用计数的内部克隆(增加 pin 计数),允许嵌套 pinning。 线程保持被钉住直到所有克隆的守卫被 drop。 安全性PinGuard 是确保对 EpochPtr 值安全并发访问的机制。 读者在通过 EpochPtr::load() 访问共享数据时必须始终持有有效的 PinGuard

Trait Implementations§

Source§

impl<'a> Clone for PinGuard<'a>

Source§

fn clone(&self) -> Self

Clone this guard to create a nested pin.

Cloning increments the pin count, and the thread remains pinned until all cloned guards are dropped. This allows multiple scopes to hold pins simultaneously.

克隆此守卫以创建嵌套 pin。

克隆会增加 pin 计数,线程保持被钉住直到所有克隆的守卫被 drop。 这允许多个作用域同时持有 pin。

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Drop for PinGuard<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PinGuard<'a>

§

impl<'a> !RefUnwindSafe for PinGuard<'a>

§

impl<'a> !Send for PinGuard<'a>

§

impl<'a> !Sync for PinGuard<'a>

§

impl<'a> Unpin for PinGuard<'a>

§

impl<'a> !UnwindSafe for PinGuard<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.