Struct crs_bind::rtos::Context [−][src]
Represents an ongoing operation which could be cancelled in the future. Inspired by contexts in the Go programming language.
Concepts
Contexts have a few important concepts: “cancellation”, “parent” and
“deadline”. A context can be cancelled by calling its Context::cancel()
method; this notifies any tasks which are waiting on its Context::done()
event. It is also cancelled automatically if and when its parent context is
cancelled, and when the last copy of it goes out of scope. A “deadline”
allows a context to be automatically cancelled at a certain timestamp; this
is implemented without creating extra tasks/threads.
Forking
A context can be “forked”, which creates a new child context. This new context can optionally be created with a deadline.
Implementations
impl Context[src]
pub fn new_global() -> Self[src]
Creates a new global context (i.e., one which has no parent or deadline).
pub fn cancel(&self)[src]
Cancels a context. This is a no-op if the context is already cancelled.
pub fn fork(&self) -> Self[src]
Forks a context. The new context’s parent is self.
pub fn fork_with_deadline(&self, deadline: Instant) -> Self[src]
Forks a context. Equivalent to Context::fork(), except that the new
context has a deadline which is the earlier of the one in self and
the one provided.
pub fn fork_with_timeout(&self, timeout: Duration) -> Self[src]
Forks a context. Equivalent to Context::fork_with_deadline(), except
that the deadline is calculated from the current time and the
provided timeout duration.
pub fn done(&self) -> impl Selectable + '_[src]
A Selectable event which occurs when the context is
cancelled. The sleep amount takes the context deadline into
consideration.
Trait Implementations
impl Clone for Context[src]
fn clone(&self) -> Context[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,