pub struct SchedulingStateMachine { /* private fields */ }
Expand description
A high-level struct
, managing the overall scheduling of tasks, to be used by
solana-unified-scheduler-pool
.
Implementations§
Source§impl SchedulingStateMachine
impl SchedulingStateMachine
pub fn has_no_active_task(&self) -> bool
pub fn has_unblocked_task(&self) -> bool
pub fn unblocked_task_queue_count(&self) -> usize
pub fn active_task_count(&self) -> u32
pub fn handled_task_count(&self) -> u32
pub fn unblocked_task_count(&self) -> u32
pub fn total_task_count(&self) -> u32
Sourcepub fn schedule_task(&mut self, task: Task) -> Option<Task>
pub fn schedule_task(&mut self, task: Task) -> Option<Task>
Schedules given task
, returning it if successful.
Returns Some(task)
if it’s immediately scheduled. Otherwise, returns None
,
indicating the scheduled task is blocked currently.
Note that this function takes ownership of the task to allow for future optimizations.
pub fn schedule_next_unblocked_task(&mut self) -> Option<Task>
Sourcepub fn deschedule_task(&mut self, task: &Task)
pub fn deschedule_task(&mut self, task: &Task)
Deschedules given scheduled task
.
This must be called exactly once for all scheduled tasks to uphold both
SchedulingStateMachine
and UsageQueue
internal state consistency at any given moment of
time. It’s serious logic error to call this twice with the same task or none at all after
scheduling. Similarly, calling this with not scheduled task is also forbidden.
Note that this function intentionally doesn’t take ownership of the task to avoid dropping
tasks inside SchedulingStateMachine
to provide an offloading-based optimization
opportunity for callers.
Sourcepub fn create_task(
transaction: RuntimeTransaction<SanitizedTransaction>,
index: usize,
usage_queue_loader: &mut impl FnMut(Pubkey) -> UsageQueue,
) -> Task
pub fn create_task( transaction: RuntimeTransaction<SanitizedTransaction>, index: usize, usage_queue_loader: &mut impl FnMut(Pubkey) -> UsageQueue, ) -> Task
Creates a new task with RuntimeTransaction<SanitizedTransaction>
with all of
its corresponding UsageQueue
s preloaded.
Closure (usage_queue_loader
) is used to delegate the (possibly multi-threaded)
implementation of UsageQueue
look-up by pubkey
to callers. It’s the
caller’s responsibility to ensure the same instance is returned from the closure, given a
particular pubkey.
Closure is used here to delegate the responsibility of primary ownership of UsageQueue
(and caching/pruning if any) to the caller. SchedulingStateMachine
guarantees that all of
shared owndership of UsageQueue
s are released and UsageQueue state is identical to just
after created, if has_no_active_task()
is true
. Also note that this is desired for
separation of concern.
Sourcepub fn reinitialize(&mut self)
pub fn reinitialize(&mut self)
Rewind the inactive state machine to be initialized
This isn’t called reset to indicate this isn’t safe to call this at any given moment.
This panics if the state machine hasn’t properly been finished (i.e. there should be no
active task) to uphold invariants of UsageQueue
s.
This method is intended to reuse SchedulingStateMachine instance (to avoid its unsafe
constructor
as much as possible) and its (possibly cached) associated UsageQueue
s for processing
other slots.
Sourcepub unsafe fn exclusively_initialize_current_thread_for_scheduling() -> Self
pub unsafe fn exclusively_initialize_current_thread_for_scheduling() -> Self
Creates a new instance of SchedulingStateMachine
with its unsafe
fields created as
well, thus carrying over unsafe
.
§Safety
Call this exactly once for each thread. See [TokenCell
] for details.
Auto Trait Implementations§
impl Freeze for SchedulingStateMachine
impl !RefUnwindSafe for SchedulingStateMachine
impl !Send for SchedulingStateMachine
impl !Sync for SchedulingStateMachine
impl Unpin for SchedulingStateMachine
impl !UnwindSafe for SchedulingStateMachine
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> 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