pub trait RankEngine: Sized {
type Config;
type Command;
type CommandEffects;
type PassStartEffects;
type PendingPass;
type PassCompletionEffects;
type InternalEffects;
// Required methods
fn new(identity: RankIdentity, config: &Self::Config) -> Result<Self>;
fn apply_command_effects(
&mut self,
command: Self::Command,
context: CommandContext,
pending_pass: Option<&mut Self::PendingPass>,
) -> Result<Self::CommandEffects>;
fn is_ready(&self) -> bool;
fn execute_pass(
&mut self,
now_ms: f64,
) -> Result<RankPass<Self::PassStartEffects, Self::PendingPass>>;
fn complete_pass(
&mut self,
pending: Self::PendingPass,
end_ms: f64,
) -> Result<Self::PassCompletionEffects>;
fn next_internal_deadline_ms(&self) -> Option<f64>;
fn process_internal_work(
&mut self,
now_ms: f64,
pass_in_flight: bool,
) -> Result<Self::InternalEffects>;
fn is_drained(&self) -> bool;
// Provided methods
fn waiting_for_external_command(&self) -> bool { ... }
fn complete_idle_group_pass(
&mut self,
_started_at_ms: f64,
_end_ms: f64,
) -> Result<Option<Self::PassCompletionEffects>> { ... }
}Expand description
One scheduler/KV/timing core.
Implementations own all single-rank scheduler state. The generalized layer owns attention-DP grouping and never inspects the command/effect payloads.
execute_pass eagerly commits a non-preemptive batch. Implementations must
not expose pass-end effects until complete_pass receives the retained
PendingPass.
Required Associated Types§
Sourcetype CommandEffects
type CommandEffects
Effects of applying one command.
Sourcetype PassStartEffects
type PassStartEffects
Effects visible when a pass starts.
Sourcetype PendingPass
type PendingPass
Opaque state retained between pass start and completion.
Sourcetype PassCompletionEffects
type PassCompletionEffects
Effects visible when a pass completes.
Sourcetype InternalEffects
type InternalEffects
Effects produced by deadline-driven internal work.
Required Methods§
Sourcefn new(identity: RankIdentity, config: &Self::Config) -> Result<Self>
fn new(identity: RankIdentity, config: &Self::Config) -> Result<Self>
Construct one rank core.
Sourcefn apply_command_effects(
&mut self,
command: Self::Command,
context: CommandContext,
pending_pass: Option<&mut Self::PendingPass>,
) -> Result<Self::CommandEffects>
fn apply_command_effects( &mut self, command: Self::Command, context: CommandContext, pending_pass: Option<&mut Self::PendingPass>, ) -> Result<Self::CommandEffects>
Apply one scheduler command.
pending_pass is the eagerly committed pass for this rank, when this
rank participated in the logical engine’s current in-flight pass.
Commands such as cancellation may mutate it to suppress effects that
were computed at pass start but must no longer become visible at pass
completion. A logical attention-DP pass can be in flight while this is
None when only sibling ranks participated; use
CommandContext::pass_in_flight for the group-wide state.
This operation must be error-atomic: returning Err must leave both
the rank and pending_pass unchanged. Command errors are recoverable
at the generalized boundary because a command targets only one rank;
use a successful command effect to represent any committed mutation.
Sourcefn execute_pass(
&mut self,
now_ms: f64,
) -> Result<RankPass<Self::PassStartEffects, Self::PendingPass>>
fn execute_pass( &mut self, now_ms: f64, ) -> Result<RankPass<Self::PassStartEffects, Self::PendingPass>>
Eagerly commit one non-preemptive pass.
Sourcefn complete_pass(
&mut self,
pending: Self::PendingPass,
end_ms: f64,
) -> Result<Self::PassCompletionEffects>
fn complete_pass( &mut self, pending: Self::PendingPass, end_ms: f64, ) -> Result<Self::PassCompletionEffects>
Release the effects of a previously committed pass.
Sourcefn next_internal_deadline_ms(&self) -> Option<f64>
fn next_internal_deadline_ms(&self) -> Option<f64>
Earliest deadline for independently modeled internal work.
The generalized engine masks this deadline while a grouped pass is in flight. A physical deadline that falls inside a model step becomes scheduler-visible only when that shared pass completes.
Sourcefn process_internal_work(
&mut self,
now_ms: f64,
pass_in_flight: bool,
) -> Result<Self::InternalEffects>
fn process_internal_work( &mut self, now_ms: f64, pass_in_flight: bool, ) -> Result<Self::InternalEffects>
Process internal work due at now_ms.
Callers may invoke this method defensively with pass_in_flight=true;
implementations must return without mutating rank state in that case.
Sourcefn is_drained(&self) -> bool
fn is_drained(&self) -> bool
Whether this rank owns no request, pass, or internal work.
Provided Methods§
Sourcefn waiting_for_external_command(&self) -> bool
fn waiting_for_external_command(&self) -> bool
Whether a ready rank is blocked only on externally commanded state.
This is narrower than having queued work. Implementations return true only when a later command can release retained ownership that prevents the ready work from advancing. Drivers use this signal to avoid repeatedly executing an effect-free, zero-duration pass while keeping genuine scheduler livelocks visible.
Sourcefn complete_idle_group_pass(
&mut self,
_started_at_ms: f64,
_end_ms: f64,
) -> Result<Option<Self::PassCompletionEffects>>
fn complete_idle_group_pass( &mut self, _started_at_ms: f64, _end_ms: f64, ) -> Result<Option<Self::PassCompletionEffects>>
Cross the shared completion boundary without a rank-local pass.
Attention-DP ranks that had no work when a sibling pass started still
participate in the group barrier. Implementations may use this hook to
release effects deferred while CommandContext::pass_in_flight was
true. end_ms is the modeled shared group boundary (the maximum rank
end), even when a wall-clock driver calls complete_pass later.
Returning None means the idle rank has no boundary effects.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".