pub struct TensorInferenceScheduler {
pub jobs: HashMap<u64, InferenceJob>,
pub next_job_id: u64,
pub config: SchedulerConfig,
pub stats: SchedulerStats,
}Expand description
Deadline-aware priority scheduler for TensorLogic inference jobs.
Uses a logical tick counter (driven by the caller) for deadline evaluation and ordering. All operations are synchronous and single-threaded; wrap with a mutex for multi-threaded use.
Fields§
§jobs: HashMap<u64, InferenceJob>All known jobs, keyed by job_id.
next_job_id: u64Monotonically increasing counter used to assign job IDs.
config: SchedulerConfigImmutable configuration.
stats: SchedulerStatsIncrementally maintained statistics.
Implementations§
Source§impl TensorInferenceScheduler
impl TensorInferenceScheduler
Sourcepub fn new(config: SchedulerConfig) -> Self
pub fn new(config: SchedulerConfig) -> Self
Creates a new scheduler with the given configuration.
Sourcepub fn submit(
&mut self,
goal: &str,
priority: u32,
deadline_tick: Option<u64>,
estimated_cost_ms: u64,
tick: u64,
) -> Option<u64>
pub fn submit( &mut self, goal: &str, priority: u32, deadline_tick: Option<u64>, estimated_cost_ms: u64, tick: u64, ) -> Option<u64>
Submits a new inference job.
Returns Some(job_id) on success, or None if the pending queue is full.
Sourcepub fn tick(&mut self, current_tick: u64)
pub fn tick(&mut self, current_tick: u64)
Advances the scheduler to current_tick.
- Expires any Running or Pending jobs whose deadline has passed.
- Promotes Pending jobs (highest priority first, ties broken by job_id ascending)
into Running state until
max_concurrentslots are filled.
Sourcepub fn complete(&mut self, job_id: u64, tick: u64) -> bool
pub fn complete(&mut self, job_id: u64, tick: u64) -> bool
Marks a Running job as Completed.
Returns false if the job is not found or is not currently Running.
Sourcepub fn cancel(&mut self, job_id: u64) -> bool
pub fn cancel(&mut self, job_id: u64) -> bool
Cancels a Pending or Running job.
Returns false if the job is not found or is already in a terminal state.
Sourcepub fn queue_depth(&self) -> usize
pub fn queue_depth(&self) -> usize
Returns the number of jobs currently in Pending state.
Sourcepub fn running_jobs(&self) -> Vec<&InferenceJob>
pub fn running_jobs(&self) -> Vec<&InferenceJob>
Returns all currently Running jobs, sorted ascending by job_id.
Sourcepub fn job(&self, job_id: u64) -> Option<&InferenceJob>
pub fn job(&self, job_id: u64) -> Option<&InferenceJob>
Looks up a job by ID.
Sourcepub fn stats(&self) -> &SchedulerStats
pub fn stats(&self) -> &SchedulerStats
Returns a reference to the current scheduler statistics.
Auto Trait Implementations§
impl Freeze for TensorInferenceScheduler
impl RefUnwindSafe for TensorInferenceScheduler
impl Send for TensorInferenceScheduler
impl Sync for TensorInferenceScheduler
impl Unpin for TensorInferenceScheduler
impl UnsafeUnpin for TensorInferenceScheduler
impl UnwindSafe for TensorInferenceScheduler
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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