Skip to main content

CycleWires

Struct CycleWires 

Source
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):

  1. Output (memoizing pull through the eval cone).
  2. Input slot (cell-aware read).
  3. 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>

Source

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.

Source

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.

Source

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>

Source§

fn get(&self, name: &str) -> Option<Value>

Look up 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> + '_>

Iterate declared names. Order is implementation-defined. Used by validators and diagnostic renderers.
Source§

fn reset(&self, name: &str) -> WriteOutcome

Reset the named input slot to its DECLARED initial value — the author’s identity element for that wire. The capture layer uses this for min/max-of-nothing (SRD-93-era fold totality): an empty measurement restores the wire to its declared unit rather than parking 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

Write 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 more
Source§

fn advance(&self, coord: u64)

Advance the underlying kernel state to coordinate coord and invalidate any memoized pulls so subsequent get calls produce values for this coord. Read more

Auto 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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more