Skip to main content

Executor

Struct Executor 

Source
pub struct Executor<C: ExecutorContext> { /* private fields */ }
Expand description

Concurrent scheduler-dispatch executor.

Implementations§

Source§

impl<C: ExecutorContext> Executor<C>

Source

pub fn new() -> Self

Source

pub fn with_config(config: ExecutorConfig) -> Self

Source

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.

Source

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.

Source

pub fn actor_is_idle(&self, root_id: &ProjectRootId) -> bool

Return true only when the actor has no queued or running executor work.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn actor_registered(&self, root_id: &ProjectRootId) -> bool

Return whether scheduler state currently has an actor for this root.

Source

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.

Source

pub fn scheduler_lock_diagnostics(&self) -> Arc<LockDiagnostics> ⓘ

Source

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.

Source

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.

Source

pub fn actor_entries(&self) -> Vec<(ProjectRootId, Arc<C>)>

Snapshot the registered root ids paired with their actor contexts.

Source

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.

Source

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.

Source

pub fn try_actor_count(&self) -> Option<usize>

Constant-time scheduler contention signal for the health reply path.

Source

pub fn submit( &self, root_id: ProjectRootId, lane: Lane, request_id: String, job: ExecutorJob<C>, ) -> CompletionHandle

Source

pub fn submit_async( &self, root_id: ProjectRootId, lane: Lane, request_id: String, job: ExecutorJob<C>, ) -> Receiver<Response> ⓘ

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn submit_maintenance_async( &self, root_id: ProjectRootId, lane: Lane, request_id: String, job: ExecutorJob<C>, ) -> Receiver<Response> ⓘ

Source

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.

Source

pub fn submit_coalescable_maintenance_async( &self, root_id: ProjectRootId, lane: Lane, request_id: String, coalesce_key: MaintenanceCoalesceKey, job: ExecutorJob<C>, ) -> Receiver<Response> ⓘ

Source

pub fn pool_size(&self) -> usize

Source

pub fn actor_cap(&self) -> usize

Source

pub fn read_cap(&self) -> usize

Source

pub fn heavy_permits(&self) -> usize

Source

pub fn interactive_reserve(&self) -> usize

Source

pub fn maintenance_cap(&self) -> usize

Source

pub fn try_dispatch_liveness_snapshot(&self) -> Option<DispatchLivenessSnapshot>

Source

pub fn try_running_read_requests(&self) -> Option<HashSet<String>>

In-memory read-job identities for management attribution; contention stays unknown.

Source

pub fn try_mutating_lane_snapshots(&self) -> Option<Vec<MutatingLaneSnapshot>>

Source

pub fn try_root_job_snapshots( &self, root_id: &ProjectRootId, current: Option<&JobCancellation>, ) -> Option<Vec<RootJobSnapshot>>

Source

pub fn try_mutating_job_state_label( &self, root_id: &ProjectRootId, request_id: &str, ) -> Option<&'static str>

Source

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.

Source

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.

Source

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.

Source

pub fn dispatch_loop_liveness(&self) -> Arc<DispatchLoopLiveness<C>> ⓘ

Progress marker of the scheduler loop, for the subc stall watchdog.

Source

pub fn nonrunnable_dispatch_count(&self) -> usize

Source

pub fn completion_counts(&self) -> (u64, u64)

Source

pub fn actor_is_fatal(&self, root_id: &ProjectRootId) -> bool

Trait Implementations§

Source§

impl<C: ExecutorContext> Default for Executor<C>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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>
where Arc<ExecutorInner<C>>: Freeze,

§

impl<C> Move for Executor<C>

§

impl<C> Send for Executor<C>
where Arc<ExecutorInner<C>>: Send,

§

impl<C> Sync for Executor<C>
where Arc<ExecutorInner<C>>: Sync,

§

impl<C> Unpin for Executor<C>
where Arc<ExecutorInner<C>>: Unpin,

§

impl<C> UnsafeUnpin for Executor<C>
where Arc<ExecutorInner<C>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more