pub struct Task {
pub id: TaskId,
pub state: AtomicUsize,
pub priority: u32,
pub future_ptr: *mut (),
pub drop_fn: Option<fn(*mut ())>,
pub poll_fn: Option<fn(*mut (), &mut Context<'_>) -> Poll<()>>,
pub on_complete: Option<fn(TaskId)>,
pub parent: Option<TaskId>,
pub children: Mutex<Vec<TaskId>>,
pub created_at: Instant,
pub waiters: Mutex<Vec<Waker>>,
}Expand description
A task in the runtime.
Tasks wrap futures and provide the machinery for scheduling and execution.
Fields§
§id: TaskIdUnique task ID.
state: AtomicUsizeCurrent state.
priority: u32Priority (lower = higher priority).
future_ptr: *mut ()The future to poll (type-erased). In real implementation, this would be a trait object or union.
drop_fn: Option<fn(*mut ())>Drop function for the future.
poll_fn: Option<fn(*mut (), &mut Context<'_>) -> Poll<()>>Poll function for the future.
on_complete: Option<fn(TaskId)>Completion callback.
parent: Option<TaskId>Parent task for structured concurrency.
children: Mutex<Vec<TaskId>>Child tasks.
created_at: InstantCreation time.
waiters: Mutex<Vec<Waker>>Join handle waiters.
Implementations§
Source§impl Task
impl Task
Sourcepub fn notify_waiters(&self)
pub fn notify_waiters(&self)
Notify waiters that task completed.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Task
impl Forget for Task
impl Move for Task
impl RefUnwindSafe for Task
impl Unpin for Task
impl UnsafeUnpin for Task
impl UnwindSafe for Task
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