Struct tokio::runtime::scheduler::current_thread::Context

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

Thread-local context.

pub(crate) to store in runtime::context.

Fields§

§handle: Arc<Handle>

Scheduler handle

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

Scheduler core, enabling the holder of Context to execute the scheduler.

§defer: Defer

Deferred tasks, usually ones that called task::yield_now().

Implementations§

source§

impl Context

source

fn run_task<R>(&self, core: Box<Core>, f: impl FnOnce() -> R) -> (Box<Core>, R)

Execute the closure with the given scheduler core stored in the thread-local context.

source

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

Blocks the current thread until an event is received by the driver, including I/O events, timer events, …

source

fn park_yield(&self, core: Box<Core>, handle: &Handle) -> Box<Core>

Checks the driver for new events without blocking the thread.

source

fn enter<R>(&self, core: Box<Core>, f: impl FnOnce() -> R) -> (Box<Core>, R)

source

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

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.