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

source

fn tick(&mut self)

Increment the tick

source

fn next_task(&mut self, worker: &Worker) -> Option<Notified<Arc<Handle>>>

Return the next notified task available to this worker.

source

fn next_local_task(&mut self) -> Option<Notified<Arc<Handle>>>

source

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.

source

fn transition_to_searching(&mut self, worker: &Worker) -> bool

source

fn transition_from_searching(&mut self, worker: &Worker)

source

fn has_tasks(&self) -> bool

source

fn should_notify_others(&self) -> bool

source

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.

source

fn transition_from_parked(&mut self, worker: &Worker) -> bool

Returns true if the transition happened.

source

fn maintenance(&mut self, worker: &Worker)

Runs maintenance work such as checking the pool’s state.

source

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.

source

fn shutdown(&mut self, handle: &Handle)

Shuts down the core.

source

fn tune_global_queue_interval(&mut self, worker: &Worker)

Auto Trait Implementations§

§

impl !RefUnwindSafe for Core

§

impl Send for Core

§

impl Sync for Core

§

impl Unpin for Core

§

impl !UnwindSafe for Core

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.