pub struct MutexData { /* private fields */ }Expand description
Mutex<T> storage — a single typed payload protected by a Rust
Mutex so concurrent Arc<MutexData> shares observe each other’s
mutations (the canonical “shared cell with exclusion” shape, mirror
of ChannelData’s Mutex<ChannelInner> interior-mutability shape).
At landing the VM is single-threaded so lock() / try_lock() are
no-op markers — the contract they preserve is “the inner value is
mutated under exclusion” (the same contract user code reasons
about). When the VM grows real concurrency, the same Mutex here
will serialize concurrent lock() calls without API churn.
The inner Option<KindedSlot> carries one strong-count share for
the wrapped value when present; take() / replace() discipline
preserves the share-discipline across set(...) (the old slot
drops, the new slot is owned by the cell).
Implementations§
Source§impl MutexData
impl MutexData
Sourcepub fn new(value: KindedSlot) -> Self
pub fn new(value: KindedSlot) -> Self
Build a MutexData wrapping value.
Sourcepub fn lock(&self)
pub fn lock(&self)
lock() — at landing a no-op marker (single-threaded VM). When
the runtime grows real concurrency, this is the acquire point
for the inner std::sync::Mutex.
Sourcepub fn try_lock(&self) -> bool
pub fn try_lock(&self) -> bool
try_lock() — at landing always returns true (single-threaded
VM; there’s no contention to fail). Mirror of lock().
Sourcepub fn get(&self) -> KindedSlot
pub fn get(&self) -> KindedSlot
Read the current value (clone of the inner KindedSlot).
KindedSlot::Clone bumps the inner share so the returned slot
is independently owned.
Sourcepub fn set(&self, new_value: KindedSlot)
pub fn set(&self, new_value: KindedSlot)
Replace the wrapped value. The prior slot drops here
(KindedSlot::Drop retires its inner share); the new slot is
owned by the cell.