pub struct SharedCellInner {
pub value: Mutex<Value>,
pub revision: AtomicU64,
pub scope_intent_dirty: Arc<AtomicU64>,
pub bit: u8,
}Expand description
A cross-kernel mutable cell for a shared-modifier wire.
When a shared output in an outer scope is bound into an
inner kernel via materialize_wiring_from_outer, both kernels’ input
slots reference the same SharedCell. Writes from inner via
set_input flow through to the cell; reads on either side
pick up the latest value.
Concurrent writers serialize at the Mutex; the current semantic is last-write-wins (lock-acquisition order). Future templated patterns (atomic-fetch-add, sum-reduction, merge, etc.) — see SRD-16 §“Open: concurrent shared mutation” — will introduce alternative cell types selected per binding declaration.
§Cross-fiber validity tracking
Each cell carries its own validity-tracking handles per
polydat/docs/design/cross_fiber_invalidation.md:
revision: AtomicU64— monotonic counter, bumped on every write. Consumer fibers cache the last revision they observed in their per-fiberlast_seenmap; a mismatch tells the cone walker to re-evaluate.scope_intent_dirty: Arc<AtomicU64>— one intent word, shared with every other cell allocated from the same word. The cell’sbitposition is set on every write, allowing consumers to do an O(1) bulk check (“any cell in this scope dirty?”) before drilling down to the per-cell revision compare.bit: u8— this cell’s position within its word. The scope keeps oneArc<AtomicU64>per 64 cells, grown on demand by the defining scope’sEngineCore::allocate_cell_bit.
The reader contract (S5 §1.1) is preserved: a producer’s
publish writes value + revision + intent bit in three
Release stores; a consumer’s check_clean walk on its next
read observes the change without any host-side ceremony.
Fields§
§value: Mutex<Value>Cell value. The mutex serialises concurrent writers and gives readers single-value atomicity.
revision: AtomicU64Monotonic revision counter. Bumped on every write
(Release); compared by consumers (Acquire) against
per-fiber last_seen.
scope_intent_dirty: Arc<AtomicU64>Defining scope’s intent-dirty bit-vector. Shared by Arc
across every cell allocated by the same scope. On every
write the producer ORs 1 << self.bit into this
(Release) so consumers’ bulk-mask check sees the scope
as dirty.
bit: u8This cell’s bit position in scope_intent_dirty. Stable
for the cell’s lifetime.
Implementations§
Sourcepub fn new(initial: Value, scope_intent_dirty: Arc<AtomicU64>, bit: u8) -> Self
pub fn new(initial: Value, scope_intent_dirty: Arc<AtomicU64>, bit: u8) -> Self
Construct a new cell with the given initial value, bound
to the defining scope’s intent-dirty word at the given
bit position within that word. Callers must allocate
(word, bit) via EngineCore::allocate_cell_bit —
the bit is not reusable for the cell’s lifetime.
Sourcepub fn publish(&self, value: Value)
pub fn publish(&self, value: Value)
Producer-side write: replace the cell’s value, bump the
revision, set the intent bit. Three Release stores
publish the write across any consumer fiber per
cross_fiber_invalidation.md §6. The mutex critical
section is held only for the value swap; the atomics
run outside it.
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more