pub trait EventDomainRun: Debug + Send {
// Required methods
fn domain(&self) -> EventDomainId;
fn enqueue(
&mut self,
dependencies: &[Arc<dyn EventToken>],
launch: &mut dyn FnMut() -> Result<()>,
) -> Result<Arc<dyn EventToken>>;
fn drain(&mut self) -> Result<()>;
// Provided method
fn enable_single_domain_coalescing(&mut self) -> bool { ... }
}Expand description
Per-execution state owned by one event domain.
§Examples
use tenferro_runtime::{EventDomainId, EventDomainRun};
fn submit(
run: &mut dyn EventDomainRun,
domain: EventDomainId,
) -> tenferro_runtime::Result<()> {
assert_eq!(run.domain(), domain);
let mut launch = || Ok(());
run.enqueue(&[], &mut launch)?;
run.drain()
}Required Methods§
Sourcefn domain(&self) -> EventDomainId
fn domain(&self) -> EventDomainId
Return the exact domain admitted by this run.
§Examples
use tenferro_runtime::{EventDomainId, EventDomainRun};
fn inspect(run: &dyn EventDomainRun, expected: EventDomainId) {
assert_eq!(run.domain(), expected);
}Sourcefn enqueue(
&mut self,
dependencies: &[Arc<dyn EventToken>],
launch: &mut dyn FnMut() -> Result<()>,
) -> Result<Arc<dyn EventToken>>
fn enqueue( &mut self, dependencies: &[Arc<dyn EventToken>], launch: &mut dyn FnMut() -> Result<()>, ) -> Result<Arc<dyn EventToken>>
Enqueue one launch after its dependency tokens.
§Errors
Returns a typed runtime error when a dependency token is incompatible
with this domain, native queue submission fails, or launch returns an
error.
The implementation must not invoke launch when dependency admission
or waiting fails. After dependencies are admitted, it invokes launch
exactly once without holding a driver lock. The closure submits work to
the native queue; it does not wait for that work to complete.
§Examples
use tenferro_runtime::EventDomainRun;
fn submit(run: &mut dyn EventDomainRun) -> tenferro_runtime::Result<()> {
let mut launched = false;
let mut launch = || {
launched = true;
Ok(())
};
run.enqueue(&[], &mut launch)?;
assert!(launched);
Ok(())
}Sourcefn drain(&mut self) -> Result<()>
fn drain(&mut self) -> Result<()>
Wait for all work already enqueued in this run.
§Errors
Returns the first driver-defined typed error, such as
crate::Error::Internal, when a queued completion reports failure or
the native queue cannot be synchronized.
Success and error are both retirement boundaries: before returning, the run must ensure that no previously enqueued work can access tensors, tokens, or native resources retained by the caller. An error reports the completion failure; it must not mean that work is still using those resources. Implementations must not unwind from this method.
Draining observes already-progressing work. It must not require another event domain’s drain call to start that work.
Dropping a run must perform equivalent best-effort retirement when explicit draining is skipped by panic unwinding. Neither explicit draining nor implicit retirement may unwind into the caller.
Provided Methods§
Sourcefn enable_single_domain_coalescing(&mut self) -> bool
fn enable_single_domain_coalescing(&mut self) -> bool
Accept the single-domain coalesced submission fast path when supported.
The scheduler calls this at most once per run, before any launch, and
only after it has proven that every scheduled location and node of the
run uses this exact domain and that the schedule contains no transfer
node. Returning true promises that same-stream submission order alone
orders this run’s nodes: the scheduler then submits each launch through
this run without dependency tokens and records no per-node completion,
keeping only the run’s own Self::drain retirement.
Returning false (the default) keeps the per-node completion contract,
so an unknown provider behaves exactly as before. A run must not return
true unless it really keeps only submission order for ordering, because
a node would otherwise be allowed to run before the node it depends on.
Operation-level barriers that a launch needs for raw or vendor work are
unaffected.
§Examples
use tenferro_runtime::EventDomainRun;
fn keeps_per_node_completions(run: &mut dyn EventDomainRun) -> bool {
!run.enable_single_domain_coalescing()
}Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".