pub struct CycleWires<'a> { /* private fields */ }Expand description
WireSource over a per-fiber kernel handle that supports the
full read surface — inputs, scope-init constants, AND computed
outputs (which need a memoizing pull(&mut state, …) to fire
the eval cone). Wraps a &mut ScopeKernel in a Mutex so the
trait stays &self-callable (and Sync) while still permitting
pull’s &mut requirement.
The Mutex is uncontended in practice: per-fiber-per-cycle
dispatch is single-threaded by construction (the fiber owns
the kernel slot exclusively for the duration of the cycle),
so lock() always succeeds without spinning. Using Mutex
rather than RefCell is a Sync requirement — async futures
returned by OpDispenser::execute are Send, which means
&ExecCtx (and through it &dyn WireSource) must be Send,
which means dyn WireSource must be Sync.
Cells held here have the lifetime of one cycle dispatch — constructed at cycle entry from the firing dispenser’s per-fiber kernel slot, dropped after the dispenser returns.
Resolution order on get(name):
- Output (memoizing pull through the eval cone).
- Input slot (cell-aware read).
- Scope-init constant.
None when the name doesn’t appear on this kernel — callers
surface as an unresolved-bindpoint error per SRD-68 I-1.
The kernel may be on any engine. Names resolve on program, the
interpreter program the kernel runs or was imaged from, whose
indices it shares (fiber_engine::agrees); the kernel is then
driven by index, so a compiled kernel pays no name lookup.
One value per name per cycle: an output read is kept for the life of
these wires — one cycle’s dispatch — so an op that references a
volatile binding twice renders one reading, although polydat
re-evaluates a volatile step on every pull. A write, a reset, or an
advance forgets every kept reading, so a read after one sees the
kernel as it is now.
Implementations§
Source§impl<'a> CycleWires<'a>
impl<'a> CycleWires<'a>
Sourcepub fn new<K: ProgramKernel + ?Sized>(kernel: &'a mut K) -> Self
pub fn new<K: ProgramKernel + ?Sized>(kernel: &'a mut K) -> Self
Wrap a scope kernel (or an interpreter kernel) for cycle-time reads; names resolve on its program. The caller holds the only outstanding borrow on the kernel for the duration of this cycle.
Sourcepub fn over(kernel: &'a mut dyn Kernel, program: Arc<PolydatProgram>) -> Self
pub fn over(kernel: &'a mut dyn Kernel, program: Arc<PolydatProgram>) -> Self
Wrap a kernel of any engine whose inputs and outputs are
program’s, in the same order.
Sourcepub fn of(kernel: &'a mut dyn Kernel) -> Self
pub fn of(kernel: &'a mut dyn Kernel) -> Self
Wrap a kernel of any engine, resolving names on the kernel
itself. For a holder with no interpreter program in hand — an
adapter probing a fork of its Arc<dyn Kernel> parent; a
compiled kernel’s name lookup is a scan, so a per-cycle path
uses Self::over.
Trait Implementations§
Source§impl<'a> WireSource for CycleWires<'a>
impl<'a> WireSource for CycleWires<'a>
Source§fn get(&self, name: &str) -> Option<Value>
fn get(&self, name: &str) -> Option<Value>
name in this kernel’s scope. Returns the current
value (cloned, owned) or None when the name is not
declared here. Callers do not retry against another kernel
— a None is the resolution result, full stop.Source§fn names(&self) -> Box<dyn Iterator<Item = String> + '_>
fn names(&self) -> Box<dyn Iterator<Item = String> + '_>
Source§fn reset(&self, name: &str) -> WriteOutcome
fn reset(&self, name: &str) -> WriteOutcome
Value::None on a typed
slot, where every downstream consumer would have to be
None-aware. Default impl returns NoSlot (read-only
sources have nothing to reset).Source§fn write(&self, name: &str, value: Value) -> WriteOutcome
fn write(&self, name: &str, value: Value) -> WriteOutcome
value into the named input slot of this kernel.
Returns WriteOutcome::Stored when the slot exists and
the value was written, WriteOutcome::NoSlot when the
kernel’s program has no input slot named name. Read moreAuto Trait Implementations§
impl<'a> !Freeze for CycleWires<'a>
impl<'a> !RefUnwindSafe for CycleWires<'a>
impl<'a> !UnwindSafe for CycleWires<'a>
impl<'a> Send for CycleWires<'a>
impl<'a> Sync for CycleWires<'a>
impl<'a> Unpin for CycleWires<'a>
impl<'a> UnsafeUnpin for CycleWires<'a>
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