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