pub struct Context {
pub name: String,
pub created_at: Instant,
/* private fields */
}
Expand description
Hierarchical context for task management and cancellation
Fields§
§name: String
Context name for debugging
created_at: Instant
When this context was created
Implementations§
Source§impl Context
impl Context
Sourcepub fn new(name: &str) -> Arc<Context>
pub fn new(name: &str) -> Arc<Context>
Create new root context (typically only used by main macro)
Sourcepub fn child(&self, name: &str) -> ContextBuilder
pub fn child(&self, name: &str) -> ContextBuilder
Create child context
Sourcepub fn spawn<F>(&self, task: F) -> JoinHandle<F::Output>
pub fn spawn<F>(&self, task: F) -> JoinHandle<F::Output>
Simple spawn (inherits current context, no child creation)
Sourcepub fn spawn_child<F, Fut>(
&self,
name: &str,
task: F,
) -> JoinHandle<Fut::Output>
pub fn spawn_child<F, Fut>( &self, name: &str, task: F, ) -> JoinHandle<Fut::Output>
Spawn task with named child context (common case shortcut)
Sourcepub fn cancelled(&self) -> WaitForCancellationFuture<'_>
pub fn cancelled(&self) -> WaitForCancellationFuture<'_>
Wait for cancellation signal (returns proper Future for tokio::select!)
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if this context is cancelled
Sourcepub fn status(&self) -> ContextStatus
pub fn status(&self) -> ContextStatus
Get status information for this context and all children
Trait Implementations§
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