pub struct SyncRegionToken<'brand> { /* private fields */ }Expand description
A brand owner that is Send + Sync and may be handed across thread
boundaries to relocate exclusive write capability.
SyncRegionToken carries the same permit semantics as
ExclusiveToken but names the region pattern
explicitly: a contiguous branded region (e.g. an allocator’s slab) whose
ownership migrates between worker threads. Moving the token to a thread
transfers the right to mutate every cell of the region; sharing &token
across threads (via crate::MelinoeCell’s Sync impl) grants concurrent
read access.
Because the token is move-only for writes yet freely borrowable for reads, the borrow checker enforces single-writer / multi-reader discipline over the whole region without a single atomic instruction or lock.
§Device-buffer ownership transfer
A device-buffer owner can store the backend’s real buffer handle in a
MelinoeCell and require SyncRegionToken<'brand> by
value on the host/device boundary. Moving the token into that boundary
transfers the sole write capability to the code that records the stream or
queue operation. Returning the token after submission or synchronization
restores host-side exclusive capability; borrowing it immutably, or calling
share, switches to shared readback/observer capability.
Implementations§
Source§impl<'brand> SyncRegionToken<'brand>
impl<'brand> SyncRegionToken<'brand>
Sourcepub const unsafe fn new_unchecked() -> SyncRegionToken<'brand>
pub const unsafe fn new_unchecked() -> SyncRegionToken<'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.
Source§impl<'brand> SyncRegionToken<'brand>
impl<'brand> SyncRegionToken<'brand>
Mint a Copy, read-only
SharedReadToken tied to this
borrow.
The returned token borrows self immutably for 'a, so while
any copy of it is live the owning token cannot be borrowed
mutably and no write permit can be formed.