Skip to main content

MutexData

Struct MutexData 

Source
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

Source

pub fn new(value: KindedSlot) -> Self

Build a MutexData wrapping value.

Source

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.

Source

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().

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for MutexData

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 = 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.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,