pub struct MailboxEmitter { /* private fields */ }Expand description
Sink-side emit handle (S2b / D231 / D232-AMEND/A′).
Producer build closures spawn long-lived Sinks that fire on every
future upstream emit — long after the build closure’s &Core
(ctx) is gone. Under the actor model the Core is owned by value
and relocates between workers, so sinks can no longer capture a
cloned Core / WeakCore. Instead they capture a ProducerEmitter
(cheap Clone: two Arcs) and post MailboxOps to the
Core-owned graphrefly_core::CoreMailbox; the BatchGuard
drain-to-quiescence loop applies them in-wave via the sync
Core::{emit,complete,error} (immediate, cascade-ordering-preserving
— D232-AMEND).
Method names mirror the old Core::{emit,complete,error}_or_defer
so sink bodies are unchanged: only the captured handle’s
construction differs (em = ctx.emitter() instead of
core_s.clone()).
The Send + Sync cross-thread producer emit handle (D249/S2c).
Holds only the id-only Arc<CoreMailbox> post side + the binding
(for the Core-gone handle-release branch). This is what an
autonomous timer task (temporal.rs, tokio::spawn-ed) captures —
it stays Send so the spawned future is Send. It deliberately
has no defer (that is the !Send owner-side path; see
ProducerEmitter).
Implementations§
Source§impl MailboxEmitter
impl MailboxEmitter
Sourcepub fn emit_or_defer(&self, node_id: NodeId, handle: HandleId)
pub fn emit_or_defer(&self, node_id: NodeId, handle: HandleId)
Post an Emit. If the owning Core is gone, release handle
(it held a retain for the would-be payload) — no leak.
Sourcepub fn complete_or_defer(&self, node_id: NodeId)
pub fn complete_or_defer(&self, node_id: NodeId)
Post a Complete. No payload handle; Core-gone is a no-op.
Sourcepub fn error_or_defer(&self, node_id: NodeId, handle: HandleId)
pub fn error_or_defer(&self, node_id: NodeId, handle: HandleId)
Post an Error. If the owning Core is gone, release the error
payload handle — no leak.
Sourcepub fn defer(&self, f: impl FnOnce(&dyn CoreFull) + Send + 'static) -> bool
pub fn defer(&self, f: impl FnOnce(&dyn CoreFull) + Send + 'static) -> bool
Post a Send cross-thread owner-side closure (D233/D249).
For an autonomous timer task (temporal.rs window_time) doing
task-side topology mutation that must run owner-side in FIFO
order — the closure captures only Send state, so it rides the
Send + Sync CoreMailbox. Returns false iff the Core is
gone (closure dropped unrun; release any captured handles).
Sourcepub fn is_core_gone(&self) -> bool
pub fn is_core_gone(&self) -> bool
Whether the owning Core has dropped (mailbox closed) — for
prompt timer-task shutdown (see ProducerEmitter::is_core_gone).
Trait Implementations§
Source§impl Clone for MailboxEmitter
impl Clone for MailboxEmitter
Source§fn clone(&self) -> MailboxEmitter
fn clone(&self) -> MailboxEmitter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more