pub struct Executor<C: ExecutorContext> { /* private fields */ }Expand description
Concurrent scheduler-dispatch executor.
Implementations§
Source§impl<C: ExecutorContext> Executor<C>
impl<C: ExecutorContext> Executor<C>
pub fn new() -> Self
pub fn with_config(config: ExecutorConfig) -> Self
Sourcepub fn register_actor(&self, root_id: ProjectRootId, ctx: Arc<C>) -> bool
pub fn register_actor(&self, root_id: ProjectRootId, ctx: Arc<C>) -> bool
Register an actor if one is not already present.
Existing actors keep their current context and scheduler state; subc
routing reuses them and reconfigures through the Mutating lane
rather than replacing the per-root ExecutorContext. Returns true when a
new actor was inserted.
Sourcepub fn remove_actor(&self, root_id: &ProjectRootId)
pub fn remove_actor(&self, root_id: &ProjectRootId)
Remove an actor from scheduler state.
This is intentionally minimal: subc uses it only for a just-created
RouteBind actor whose configure failed before any route was installed, so
there is no in-flight work to quiesce. The removed ExecutorContext is
dropped after releasing the scheduler lock so watcher/LSP teardown never
runs under that mutex.
Sourcepub fn actor_is_idle(&self, root_id: &ProjectRootId) -> bool
pub fn actor_is_idle(&self, root_id: &ProjectRootId) -> bool
Return true only when the actor has no queued or running executor work.
Sourcepub fn try_actor_is_idle(&self, root_id: &ProjectRootId) -> Option<bool>
pub fn try_actor_is_idle(&self, root_id: &ProjectRootId) -> Option<bool>
Idle probe for maintenance sweeps that waits at most
[SCHEDULER_PROBE_WAIT] for the scheduler lock. A contended scheduler
is reported separately so root retirement can conservatively wait for
the next sweep without stalling the module loop.
Sourcepub fn retire_idle_actor_in_background(&self, root_id: &ProjectRootId) -> bool
pub fn retire_idle_actor_in_background(&self, root_id: &ProjectRootId) -> bool
Forget an idle actor and drop its root-scoped registries off the scheduler thread. This is reserved for roots whose project directory no longer exists; retained existing roots are reused on a later bind.
Sourcepub fn try_retire_idle_actor_in_background(
&self,
root_id: &ProjectRootId,
) -> Option<bool>
pub fn try_retire_idle_actor_in_background( &self, root_id: &ProjectRootId, ) -> Option<bool>
Self::retire_idle_actor_in_background for the subc frame loop:
None when the scheduler lock stays contended past
[SCHEDULER_PROBE_WAIT], so the caller retries on its next sweep.
Sourcepub fn cancel_queued_maintenance(&self, root_id: &ProjectRootId) -> usize
pub fn cancel_queued_maintenance(&self, root_id: &ProjectRootId) -> usize
Cancel maintenance jobs that have not started for one retained actor.
Interactive work and already-running maintenance remain untouched. Each cancelled job receives a normal completion so its caller can settle bookkeeping through the same path as an executed job.
Sourcepub fn cancel_queued_root_maintenance(&self, root_id: &ProjectRootId) -> usize
pub fn cancel_queued_root_maintenance(&self, root_id: &ProjectRootId) -> usize
When a root becomes unbound, cancel queued maintenance and metadata. Started provider commits retain their result. Running maintenance checks at checkpoints whether the root stayed unbound past the abandonment grace.
Sourcepub fn cancel_root_maintenance(&self, root_id: &ProjectRootId) -> usize
pub fn cancel_root_maintenance(&self, root_id: &ProjectRootId) -> usize
Cancel queued maintenance and signal running root work at its checkpoints. Interactive tools other than inspect retain their normal completion path.
Sourcepub fn actor_registered(&self, root_id: &ProjectRootId) -> bool
pub fn actor_registered(&self, root_id: &ProjectRootId) -> bool
Return whether scheduler state currently has an actor for this root.
Sourcepub fn actor_context(&self, root_id: &ProjectRootId) -> Option<Arc<C>>
pub fn actor_context(&self, root_id: &ProjectRootId) -> Option<Arc<C>>
Snapshot one actor context without retaining the scheduler lock while maintenance drops root-scoped resources.
pub fn scheduler_lock_diagnostics(&self) -> Arc<LockDiagnostics> ⓘ
Sourcepub fn try_actor_context(
&self,
root_id: &ProjectRootId,
) -> Option<Option<Arc<C>>>
pub fn try_actor_context( &self, root_id: &ProjectRootId, ) -> Option<Option<Arc<C>>>
Self::actor_context waiting at most [SCHEDULER_PROBE_WAIT] for
the scheduler lock: the outer None means it stayed contended. The subc frame
loop’s maintenance sweeps use this and retry on the next sweep. Request
routing keeps the blocking form, because there a missing actor and a
busy scheduler mean different things.
Sourcepub fn actor_contexts(&self) -> Vec<Arc<C>>
pub fn actor_contexts(&self) -> Vec<Arc<C>>
Snapshot the registered actor contexts.
The returned Arcs keep contexts alive after the scheduler lock is
released, so callers can run teardown without holding executor state.
Sourcepub fn actor_entries(&self) -> Vec<(ProjectRootId, Arc<C>)>
pub fn actor_entries(&self) -> Vec<(ProjectRootId, Arc<C>)>
Snapshot the registered root ids paired with their actor contexts.
Sourcepub fn try_actor_entries(&self) -> Option<Vec<(ProjectRootId, Arc<C>)>>
pub fn try_actor_entries(&self) -> Option<Vec<(ProjectRootId, Arc<C>)>>
Non-blocking variant for the health path: the probe reply must stay cheap under any load, so it skips the actor list (reported as busy) rather than waiting on the scheduler state lock.
Sourcepub fn actor_count(&self) -> usize
pub fn actor_count(&self) -> usize
Registered actor count under the scheduler lock. Tests that assert a
bind had no actor side effect use this rather than the try-lock form,
which reports contention (None) instead of a count.
Sourcepub fn try_actor_count(&self) -> Option<usize>
pub fn try_actor_count(&self) -> Option<usize>
Constant-time scheduler contention signal for the health reply path.
pub fn submit( &self, root_id: ProjectRootId, lane: Lane, request_id: String, job: ExecutorJob<C>, ) -> CompletionHandle
pub fn submit_async( &self, root_id: ProjectRootId, lane: Lane, request_id: String, job: ExecutorJob<C>, ) -> Receiver<Response> ⓘ
Sourcepub fn submit_cancellable_async(
&self,
root_id: ProjectRootId,
lane: Lane,
request_id: String,
job: ExecutorJob<C>,
) -> (Receiver<Response>, JobCancellation)
pub fn submit_cancellable_async( &self, root_id: ProjectRootId, lane: Lane, request_id: String, job: ExecutorJob<C>, ) -> (Receiver<Response>, JobCancellation)
Submit an interactive job with an exact-job cancellation token.
The returned token cancels THIS job only (queued: removed and settled
with request_cancelled; running: signalled cooperatively). The job
observes the token via current_job_cancellation.
Sourcepub fn submit_tool_call_cancellable_async(
&self,
root_id: ProjectRootId,
lane: Lane,
request_id: String,
tool: &str,
job: ExecutorJob<C>,
) -> (Receiver<Response>, JobCancellation)
pub fn submit_tool_call_cancellable_async( &self, root_id: ProjectRootId, lane: Lane, request_id: String, tool: &str, job: ExecutorJob<C>, ) -> (Receiver<Response>, JobCancellation)
Executor::submit_cancellable_async for a tool call: the job is
labelled with the tool’s name, so the census and the blockers a
waiting bind reports say which tool a long-running job is running.
Sourcepub fn submit_tool_call_with_cancellation_async(
&self,
root_id: ProjectRootId,
lane: Lane,
request_id: String,
tool: &str,
job: ExecutorJob<C>,
cancellation: JobCancellation,
) -> Receiver<Response> ⓘ
pub fn submit_tool_call_with_cancellation_async( &self, root_id: ProjectRootId, lane: Lane, request_id: String, tool: &str, job: ExecutorJob<C>, cancellation: JobCancellation, ) -> Receiver<Response> ⓘ
Allows a receipt deadline to cancel admission even while submission is waiting for the scheduler state lock on a blocking worker.
Sourcepub fn submit_bind_cancellable_async(
&self,
root_id: ProjectRootId,
request_id: String,
job: RepeatableJob<C>,
) -> (Receiver<Response>, JobCancellation)
pub fn submit_bind_cancellable_async( &self, root_id: ProjectRootId, request_id: String, job: RepeatableJob<C>, ) -> (Receiver<Response>, JobCancellation)
Submit a route-bind configure (a request id starting subc-bind-)
that may run more than once, with an exact-job cancellation token.
Unlike Executor::submit_cancellable_async, the scheduler may admit
it beside a running maintenance job or readers of its actor with only a
shared hold on the epoch gate; see request_exclusive_rerun for how a run
that must change the root hands its worker back.
Sourcepub fn cancel_job(
&self,
root_id: &ProjectRootId,
token: &JobCancellation,
) -> JobCancelOutcome
pub fn cancel_job( &self, root_id: &ProjectRootId, token: &JobCancellation, ) -> JobCancelOutcome
Cancel one exact job by its token.
Queued jobs are removed and settled immediately; running jobs are signalled and return through their normal completion path at the next cooperative checkpoint. Jobs that sealed their commit finish normally.
Sourcepub fn cancel_job_before_execution(
&self,
root_id: &ProjectRootId,
token: &JobCancellation,
) -> PreExecutionCancelOutcome
pub fn cancel_job_before_execution( &self, root_id: &ProjectRootId, token: &JobCancellation, ) -> PreExecutionCancelOutcome
Cancel a route job only while its command closure has not started.
Detaching a route must discard work that cannot produce a live reply, while a command already executing remains eligible for session replay. A dispatched job may already reserve scheduler capacity; its worker sees the cancelled token before invoking the closure and releases that reservation through the normal completion event.
pub fn submit_maintenance_async( &self, root_id: ProjectRootId, lane: Lane, request_id: String, job: ExecutorJob<C>, ) -> Receiver<Response> ⓘ
Sourcepub fn submit_unbound_teardown_async(
&self,
root_id: ProjectRootId,
request_id: String,
job: ExecutorJob<C>,
) -> Receiver<Response> ⓘ
pub fn submit_unbound_teardown_async( &self, root_id: ProjectRootId, request_id: String, job: ExecutorJob<C>, ) -> Receiver<Response> ⓘ
Final persistence is allowed after unbind so TTL eviction does not lose retained deltas. This exception does not admit indexing or refresh work.
pub fn submit_coalescable_maintenance_async( &self, root_id: ProjectRootId, lane: Lane, request_id: String, coalesce_key: MaintenanceCoalesceKey, job: ExecutorJob<C>, ) -> Receiver<Response> ⓘ
pub fn pool_size(&self) -> usize
pub fn actor_cap(&self) -> usize
pub fn read_cap(&self) -> usize
pub fn heavy_permits(&self) -> usize
pub fn interactive_reserve(&self) -> usize
pub fn maintenance_cap(&self) -> usize
pub fn try_dispatch_liveness_snapshot(&self) -> Option<DispatchLivenessSnapshot>
Sourcepub fn try_running_read_requests(&self) -> Option<HashSet<String>>
pub fn try_running_read_requests(&self) -> Option<HashSet<String>>
In-memory read-job identities for management attribution; contention stays unknown.
pub fn try_mutating_lane_snapshots(&self) -> Option<Vec<MutatingLaneSnapshot>>
pub fn try_root_job_snapshots( &self, root_id: &ProjectRootId, current: Option<&JobCancellation>, ) -> Option<Vec<RootJobSnapshot>>
pub fn try_mutating_job_state_label( &self, root_id: &ProjectRootId, request_id: &str, ) -> Option<&'static str>
Sourcepub fn bind_blocker_snapshot(
&self,
root_id: &ProjectRootId,
request_id: &str,
) -> BindBlockerSnapshot
pub fn bind_blocker_snapshot( &self, root_id: &ProjectRootId, request_id: &str, ) -> BindBlockerSnapshot
Snapshot RouteBind blockers, waiting for the scheduler lock if it is held. The module’s bind-deadline refusal uses it to name what held the bind; it takes the same lock right after to cancel the bind, so waiting here costs nothing extra.
Sourcepub fn try_bind_blocker_snapshot(
&self,
root_id: &ProjectRootId,
request_id: &str,
) -> Option<BindBlockerSnapshot>
pub fn try_bind_blocker_snapshot( &self, root_id: &ProjectRootId, request_id: &str, ) -> Option<BindBlockerSnapshot>
Snapshot RouteBind blockers without waiting on scheduler state. The subc health path uses this only for a delayed-bind breadcrumb, so contention is reported as scheduler busy rather than delaying the transport loop.
Sourcepub fn try_take_long_running_interactive_jobs(
&self,
minimum_age: Duration,
) -> Option<Vec<LongRunningInteractiveJobSnapshot>>
pub fn try_take_long_running_interactive_jobs( &self, minimum_age: Duration, ) -> Option<Vec<LongRunningInteractiveJobSnapshot>>
Return each over-age interactive occupant once. Marking happens under the scheduler lock so repeated transport-loop censuses cannot flood logs while the same job remains stuck.
Sourcepub fn dispatch_loop_liveness(&self) -> Arc<DispatchLoopLiveness<C>> ⓘ
pub fn dispatch_loop_liveness(&self) -> Arc<DispatchLoopLiveness<C>> ⓘ
Progress marker of the scheduler loop, for the subc stall watchdog.
pub fn nonrunnable_dispatch_count(&self) -> usize
pub fn completion_counts(&self) -> (u64, u64)
pub fn actor_is_fatal(&self, root_id: &ProjectRootId) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<C> !RefUnwindSafe for Executor<C>
impl<C> !UnwindSafe for Executor<C>
impl<C> Forget for Executor<C>
impl<C> Freeze for Executor<C>
impl<C> Move for Executor<C>
impl<C> Send for Executor<C>
impl<C> Sync for Executor<C>
impl<C> Unpin for Executor<C>
impl<C> UnsafeUnpin for Executor<C>where
Arc<ExecutorInner<C>>: UnsafeUnpin,
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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