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>
impl<'brand> ThreadLocalToken<'brand>
Sourcepub const unsafe fn new_unchecked() -> ThreadLocalToken<'brand>
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.