pub struct WriteBuffer<T> { /* private fields */ }Expand description
Buffers writes to state cells and resolves same-cell write hazards within
one delta cycle by canonical-key order, never by push/thread/arrival order
(SC-010, SC-012). Generic over T so Task 7 (NBA commit) reuses this
instead of hand-rolling its own last-write-wins resolver.
Not reused by commit_blocking_write: a blocking write commits
synchronously, one call, one cell, inside one resume(); two processes’
blocking writes to the same cell in the same Active pass are two separate,
sequential commit_blocking_write calls already made in canonical
dispatch order, so the last call to physically run already is the
last-write-wins outcome — there is no multi-entry buffer to resolve.
Implementations§
Source§impl<T> WriteBuffer<T>
impl<T> WriteBuffer<T>
pub fn new() -> Self
pub fn push(&mut self, key: CanonicalEventKey, cell: StateCellId, value: T)
Sourcepub fn resolve_last_write_wins(self) -> Vec<(StateCellId, T)>
pub fn resolve_last_write_wins(self) -> Vec<(StateCellId, T)>
Groups buffered writes by StateCellId and keeps, for each cell,
the entry with the maximum CanonicalEventKey — comparing by
canonical key, never by push/Vec insertion order. Output order is
by StateCellId (stable, deterministic — not caller-order-dependent).