Skip to main content

ThreadLocalToken

Struct ThreadLocalToken 

Source
pub struct ThreadLocalToken<'brand> { /* private fields */ }
Expand description

A brand owner that is statically pinned to one thread.

ThreadLocalToken provides the same read/write permit interface as ExclusiveToken—a & borrow is a ReadPermit and a &mut borrow is a WritePermit—but it deliberately implements neither Send nor Sync (it carries a *const () phantom). The whole capability, and therefore every cell it governs, is consequently un-sendable: the compiler rejects any attempt to move the access right to another thread.

Use this brand for allocator metadata that must never leave its owning thread—free lists, bump cursors, and other structures whose soundness rests on single-thread confinement rather than synchronisation.

Implementations§

Source§

impl<'brand> ThreadLocalToken<'brand>

Source

pub const unsafe fn new_unchecked() -> ThreadLocalToken<'brand>

Construct a token without proving brand uniqueness.

§Safety

The caller must guarantee that no other token for the same 'brand exists for the lifetime of the returned value. Violating this allows two write permits of one brand to coexist, which is undefined behaviour.

Trait Implementations§

Source§

impl<'brand> Debug for ThreadLocalToken<'brand>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'brand> !Send for ThreadLocalToken<'brand>

§

impl<'brand> !Sync for ThreadLocalToken<'brand>

§

impl<'brand> Freeze for ThreadLocalToken<'brand>

§

impl<'brand> RefUnwindSafe for ThreadLocalToken<'brand>

§

impl<'brand> Unpin for ThreadLocalToken<'brand>

§

impl<'brand> UnsafeUnpin for ThreadLocalToken<'brand>

§

impl<'brand> UnwindSafe for ThreadLocalToken<'brand>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.