Core

Struct Core 

Source
struct Core {
    tick: u32,
    lifo_enabled: bool,
    run_queue: Local<Arc<Handle>>,
    is_searching: bool,
    is_shutdown: bool,
    is_traced: bool,
    had_driver: HadDriver,
    enable_eager_driver_handoff: 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_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

§had_driver: HadDriver

Whether or not the worker has just returned from a park in which we parked on the I/O driver.

§enable_eager_driver_handoff: bool

If true, the worker should eagerly notify another worker when polling the first task after returning from a park in which it parked on the I/O or time driver.

§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) -> bool

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 Freeze for Core

§

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 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

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