Struct tokio::runtime::scheduler::multi_thread::idle::Idle

source ·
pub(super) struct Idle {
    state: AtomicUsize,
    num_workers: usize,
}

Fields§

§state: AtomicUsize

Tracks both the number of searching workers and the number of unparked workers.

Used as a fast-path to avoid acquiring the lock when needed.

§num_workers: usize

Total number of workers.

Implementations§

source§

impl Idle

source

pub(super) fn new(num_workers: usize) -> (Idle, Synced)

source

pub(super) fn worker_to_notify(&self, shared: &Shared) -> Option<usize>

If there are no workers actively searching, returns the index of a worker currently sleeping.

source

pub(super) fn transition_worker_to_parked( &self, shared: &Shared, worker: usize, is_searching: bool, ) -> bool

Returns true if the worker needs to do a final check for submitted work.

source

pub(super) fn transition_worker_to_searching(&self) -> bool

source

pub(super) fn transition_worker_from_searching(&self) -> bool

A lightweight transition from searching -> running.

Returns true if this is the final searching worker. The caller must notify a new worker.

source

pub(super) fn unpark_worker_by_id( &self, shared: &Shared, worker_id: usize, ) -> bool

Unpark a specific worker. This happens if tasks are submitted from within the worker’s park routine.

Returns true if the worker was parked before calling the method.

source

pub(super) fn is_parked(&self, shared: &Shared, worker_id: usize) -> bool

Returns true if worker_id is contained in the sleep set.

source

fn notify_should_wakeup(&self) -> bool

Auto Trait Implementations§

§

impl !Freeze for Idle

§

impl RefUnwindSafe for Idle

§

impl Send for Idle

§

impl Sync for Idle

§

impl Unpin for Idle

§

impl UnwindSafe for Idle

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

§

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

§

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.