pub struct ScopeKernel<M> { /* private fields */ }Expand description
Typed wrapper around a kernel of any engine.
Construction via this type goes through the subcontext protocol
(subcontext_builder → finalize → spawn), which builds each
child on its parent’s engine; a root is wrapped with
wrap_root_kernel.
Implementations§
Source§impl<M> ScopeKernel<M>
impl<M> ScopeKernel<M>
Enumerate every shared cell visible at this scope: the
kernel’s Kernel::cells_in_scope, its own and those it
carries for its descendants.
Sourcepub fn name(&self) -> &ChildName
pub fn name(&self) -> &ChildName
The structured name this kernel was spawned under (for child kernels) or its self-label (for root kernels).
Sourcepub fn site(&self) -> &SourceContext
pub fn site(&self) -> &SourceContext
Diagnostic site for this kernel’s construction.
Sourcepub fn lock_inner(&self) -> MutexGuard<'_, Box<dyn Kernel>>
pub fn lock_inner(&self) -> MutexGuard<'_, Box<dyn Kernel>>
Borrow the underlying kernel. The lock is released when the returned guard is dropped. Exposed for callers that drive the kernel directly.
Sourcepub fn consumers(&self) -> Vec<RegisteredPullConsumer>
pub fn consumers(&self) -> Vec<RegisteredPullConsumer>
The pull consumers registered with this kernel. Used by the activity-side fixture adapter at seal time.
Sourcepub fn has_child(&self, name: &ChildName) -> bool
pub fn has_child(&self, name: &ChildName) -> bool
Whether name is recorded in this kernel’s named-child
registry. Diagnostic; the subcontext tests assert against this.
Sourcepub fn release_child(&self, name: &ChildName)
pub fn release_child(&self, name: &ChildName)
Drop the named child from this kernel’s registry. The child kernel itself is unaffected — only the registry entry. After release, the same name may be spawned again (typical for comprehension scopes that re-traverse per iteration). See subcontext_construction.md §4.1.
Sourcepub fn subcontext_builder(&self) -> SubcontextBuilder<M>
pub fn subcontext_builder(&self) -> SubcontextBuilder<M>
Begin construction of a child sub-context
(subcontext_construction.md §1): the builder takes the
parent’s ParentView — its names, modifiers, ledger, and
in-scope cells, which is everything finalize reads of a
parent — accumulates
module matter, and produces a closed ScopeModule artifact
at finalize. It holds no reference to the parent kernel, so a
caller that only has a kernel needs no ScopeKernel to stand up
a child.
Sourcepub fn spawn(
self: &Arc<Self>,
name: ChildName,
artifact: ScopeModule<Child<M>>,
) -> Result<ScopeKernel<Child<M>>, ContractViolation>
pub fn spawn( self: &Arc<Self>, name: ChildName, artifact: ScopeModule<Child<M>>, ) -> Result<ScopeKernel<Child<M>>, ContractViolation>
Spawn a child kernel from a closed ScopeModule
artifact (subcontext_construction.md §4): this is the single
chokepoint where every cross-binding is resolved.
The artifact arrives with Rule 1 (name closure) and Rule 2
(the shared write-through rewrite) already applied by
SubcontextBuilder::finalize. Spawn instantiates the
closed program on this parent’s engine
(ScopeModule::instantiate_under), whose binder does the
live binding: attaches every parent-visible SharedCell to
a matching child slot and forwards the rest as transit
(Rule 2’s cell attach, SC8), value-copies or cell-attaches
parent outputs into child externs (Rules 4 and 5),
initializes the child so its consts see post-bind inputs
(Rule 3), and freezes the scope coordinates. A refused copy or
a failing const is ContractViolation::Bind. Per-cycle
publication to the cells is Self::commit_write_throughs.
Sourcepub fn write_throughs(&self) -> &[WriteThroughBinding]
pub fn write_throughs(&self) -> &[WriteThroughBinding]
The Rule 2 write-through bindings carried by this kernel.
Empty for the vast majority of kernels; populated only
when the artifact’s finalize rewrote a child export to
a parent shared cell write.
Sourcepub fn commit_write_throughs(&self) -> Result<(), String>
pub fn commit_write_throughs(&self) -> Result<(), String>
Per-cycle Rule 2 commit: pulls every write-through’s
synthetic source output (__write_<X>) and stores its
value through the corresponding child input slot for
<X>. Because materialize_wiring_from_outer attached the parent’s
SharedCell to that slot, the write propagates to the
cell, where it becomes visible to the parent and to any
sibling that shares the same cell.
No-op for kernels with no write-throughs.
TYPE-STABLE (scope_model.md §6.1): each pending
value passes the boundary of Kernel::commit_write_throughs:
matching types pass, catalog adapters heal (widening), and an
unhealable mismatch is an Err at the write site.
Trait Implementations§
Auto Trait Implementations§
impl<M> !Freeze for ScopeKernel<M>
impl<M> RefUnwindSafe for ScopeKernel<M>
impl<M> Send for ScopeKernel<M>
impl<M> Sync for ScopeKernel<M>
impl<M> Unpin for ScopeKernel<M>
impl<M> UnsafeUnpin for ScopeKernel<M>
impl<M> UnwindSafe for ScopeKernel<M>
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