pub struct TaskStats {
pub id: TaskId,
pub status: TaskStatus,
pub priority: Priority,
pub spawn_time: Instant,
pub start_time: Option<Instant>,
pub completion_time: Option<Instant>,
pub cpu_time_ns: u64,
}Expand description
Detailed statistics about a specific task.
Task statistics report the lifecycle timing the executor actually tracks: spawn, start, and completion timestamps from a monotonic high-resolution clock, plus the derived execution duration.
Fields§
§id: TaskIdTask identifier
status: TaskStatusCurrent status
priority: PriorityPriority level
spawn_time: InstantWhen the task was spawned
start_time: Option<Instant>When the task started executing (if started)
completion_time: Option<Instant>When the task completed (if completed)
cpu_time_ns: u64Total CPU time used (nanoseconds), derived from the lifecycle start/completion timestamps.
Implementations§
Source§impl TaskStats
impl TaskStats
Sourcepub fn execution_time(&self) -> Option<Duration>
pub fn execution_time(&self) -> Option<Duration>
Returns the total execution time of the task, if available.
§Returns
Some(duration) if the task has completed execution, None if still running or queued.
Sourcepub fn queue_time(&self) -> Option<Duration>
pub fn queue_time(&self) -> Option<Duration>
Returns the time the task spent in the queue before execution.
§Returns
Some(duration_since_spawn)if task is still queuedSome(queue_duration)if task has started executionNoneif timing information is unavailable
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Returns whether the task is currently active (queued or running).
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns whether the task has reached a terminal state.