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: DeferDeferred tasks, usually ones that called task::yield_now().
Implementations§
Source§impl Context
impl Context
Sourcefn run_task<R>(&self, core: Box<Core>, f: impl FnOnce() -> R) -> (Box<Core>, R)
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.
Sourcefn park(&self, core: Box<Core>, handle: &Handle) -> Box<Core>
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, …
Sourcefn park_yield(&self, core: Box<Core>, handle: &Handle) -> Box<Core>
fn park_yield(&self, core: Box<Core>, handle: &Handle) -> Box<Core>
Checks the driver for new events without blocking the thread.
fn has_pending_work(&self, core: &Core) -> bool
fn park_internal( &self, core: Box<Core>, handle: &Handle, driver: &mut Driver, duration: Option<Duration>, ) -> Box<Core>
fn enter<R>(&self, core: Box<Core>, f: impl FnOnce() -> R) -> (Box<Core>, R)
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 UnsafeUnpin for Context
impl !UnwindSafe for Context
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more