struct Core {
tick: u32,
lifo_slot: Option<Notified<Arc<Handle>>>,
lifo_enabled: bool,
run_queue: Local<Arc<Handle>>,
is_searching: bool,
is_shutdown: bool,
is_traced: bool,
park: Option<Parker>,
stats: Stats,
global_queue_interval: u32,
rand: FastRand,
}
Expand description
Core data
Fields§
§tick: u32
Used to schedule bookkeeping tasks every so often.
lifo_slot: Option<Notified<Arc<Handle>>>
When a task is scheduled from a worker, it is stored in this slot. The worker will check this slot for a task before checking the run queue. This effectively results in the last scheduled task to be run next (LIFO). This is an optimization for improving locality which benefits message passing patterns and helps to reduce latency.
lifo_enabled: bool
When true
, locally scheduled tasks go to the LIFO slot. When false
,
they go to the back of the run_queue
.
run_queue: Local<Arc<Handle>>
The worker-local run queue.
is_searching: bool
True if the worker is currently searching for more work. Searching involves attempting to steal from other workers.
is_shutdown: bool
True if the scheduler is being shutdown
is_traced: bool
True if the scheduler is being traced
park: Option<Parker>
Parker
Stored in an Option
as the parker is added / removed to make the
borrow checker happy.
stats: Stats
Per-worker runtime stats
global_queue_interval: u32
How often to check the global queue
rand: FastRand
Fast random number generator.
Implementations§
source§impl Core
impl Core
sourcefn next_task(&mut self, worker: &Worker) -> Option<Notified<Arc<Handle>>>
fn next_task(&mut self, worker: &Worker) -> Option<Notified<Arc<Handle>>>
Return the next notified task available to this worker.
fn next_local_task(&mut self) -> Option<Notified<Arc<Handle>>>
sourcefn steal_work(&mut self, worker: &Worker) -> Option<Notified<Arc<Handle>>>
fn steal_work(&mut self, worker: &Worker) -> Option<Notified<Arc<Handle>>>
Function responsible for stealing tasks from another worker
Note: Only if less than half the workers are searching for tasks to steal a new worker will actually try to steal. The idea is to make sure not all workers will be trying to steal at the same time.
fn transition_to_searching(&mut self, worker: &Worker) -> bool
fn transition_from_searching(&mut self, worker: &Worker)
fn has_tasks(&self) -> bool
fn should_notify_others(&self) -> bool
sourcefn transition_to_parked(&mut self, worker: &Worker) -> bool
fn transition_to_parked(&mut self, worker: &Worker) -> bool
Prepares the worker state for parking.
Returns true if the transition happened, false if there is work to do first.
sourcefn transition_from_parked(&mut self, worker: &Worker) -> bool
fn transition_from_parked(&mut self, worker: &Worker) -> bool
Returns true
if the transition happened.
sourcefn maintenance(&mut self, worker: &Worker)
fn maintenance(&mut self, worker: &Worker)
Runs maintenance work such as checking the pool’s state.
sourcefn pre_shutdown(&mut self, worker: &Worker)
fn pre_shutdown(&mut self, worker: &Worker)
Signals all tasks to shut down, and waits for them to complete. Must run before we enter the single-threaded phase of shutdown processing.