Struct tokio::runtime::scheduler::multi_thread::worker::Context

source ·
pub(crate) struct Context {
    worker: Arc<Worker>,
    core: RefCell<Option<Box<Core>>>,
    pub(crate) defer: Defer,
}
Expand description

Thread-local context

Fields§

§worker: Arc<Worker>

Worker

§core: RefCell<Option<Box<Core>>>

Core data

§defer: Defer

Tasks to wake after resource drivers are polled. This is mostly to handle yielded tasks.

Implementations§

source§

impl Context

source

fn run(&self, core: Box<Core>) -> Result<Box<Core>, ()>

source

fn run_task( &self, task: Notified<Arc<Handle>>, core: Box<Core>, ) -> Result<Box<Core>, ()>

source

fn reset_lifo_enabled(&self, core: &mut Core)

source

fn assert_lifo_enabled_is_correct(&self, core: &Core)

source

fn maintenance(&self, core: Box<Core>) -> Box<Core>

source

fn park(&self, core: Box<Core>) -> Box<Core>

Parks the worker thread while waiting for tasks to execute.

This function checks if indeed there’s no more work left to be done before parking. Also important to notice that, before parking, the worker thread will try to take ownership of the Driver (IO/Time) and dispatch any events that might have fired. Whenever a worker thread executes the Driver loop, all waken tasks are scheduled in its own local queue until the queue saturates (ntasks > LOCAL_QUEUE_CAPACITY). When the local queue is saturated, the overflow tasks are added to the injection queue from where other workers can pick them up. Also, we rely on the workstealing algorithm to spread the tasks amongst workers after all the IOs get dispatched

source

fn park_timeout(&self, core: Box<Core>, duration: Option<Duration>) -> Box<Core>

source

pub(crate) fn defer(&self, waker: &Waker)

source

pub(crate) fn get_worker_index(&self) -> usize

Auto Trait Implementations§

§

impl !Freeze for Context

§

impl !RefUnwindSafe for Context

§

impl Send for Context

§

impl !Sync for Context

§

impl Unpin for Context

§

impl !UnwindSafe for Context

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.