pub struct TaskTable { /* private fields */ }Expand description
Unified registry of all tasks: the root loop plus one child per sub-agent. The sole source of
truth for schedulability and lineage; the AgentProcess view is derived from it.
Implementations§
Source§impl TaskTable
impl TaskTable
pub fn new() -> Self
pub fn insert(&mut self, tcb: Tcb)
pub fn get(&self, id: &str) -> Option<&Tcb>
pub fn get_mut(&mut self, id: &str) -> Option<&mut Tcb>
pub fn all(&self) -> &[Tcb]
pub fn children_of(&self, parent: &str) -> Vec<&Tcb>
pub fn wait_index(&self) -> &WaitIndex
Sourcepub fn wait_for_timer(&mut self, task_id: &str, deadline: LogicalDeadline)
pub fn wait_for_timer(&mut self, task_id: &str, deadline: LogicalDeadline)
Register task_id as waiting on a deadline.
Sourcepub fn wake_expired_timers(&mut self, now_ms: u64) -> Vec<TaskId> ⓘ
pub fn wake_expired_timers(&mut self, now_ms: u64) -> Vec<TaskId> ⓘ
spc_003-05: wake every task whose Timer deadline is <= now_ms. Returns the woken ids.
Sourcepub fn wait_for_condition(&mut self, task_id: &str, condition: &WaitCondition)
pub fn wait_for_condition(&mut self, task_id: &str, condition: &WaitCondition)
Register task_id as waiting on an arbitrary WaitCondition.
Sourcepub fn wake(&mut self, key: &WaitKey) -> Vec<TaskId> ⓘ
pub fn wake(&mut self, key: &WaitKey) -> Vec<TaskId> ⓘ
spc_003-06: wake every task waiting on exactly key. Idempotent — see
super::wait_index::WaitIndex::wake.
Sourcepub fn register_wait_set(&mut self, task_id: &str, wait_set: WaitSet)
pub fn register_wait_set(&mut self, task_id: &str, wait_set: WaitSet)
spc_003 debt closure: register task_id against a full WaitSet (Any/All over
multiple heterogeneous conditions) — see super::wait_index::WaitIndex::register_wait_set.
Sourcepub fn clear_wait(&mut self, task_id: &str)
pub fn clear_wait(&mut self, task_id: &str)
Clear every durable wait condition for a task without changing its lifecycle.
Sourcepub fn notify(&mut self, key: &WaitKey) -> Vec<TaskId> ⓘ
pub fn notify(&mut self, key: &WaitKey) -> Vec<TaskId> ⓘ
spc_003 debt closure: notify every task registered under key via
Self::register_wait_set, returning those whose whole WaitSet is now satisfied — see
super::wait_index::WaitIndex::notify.
Sourcepub fn root_id(&self) -> Option<TaskId>
pub fn root_id(&self) -> Option<TaskId>
spc_002-04: the id of this table’s own structural root — the task with no parent — the
kernel-owned fact a spawn’s parent derives from instead of a hardcoded "root" literal.
None only for a table that has not yet had its root task inserted.
Sourcepub fn cancel_subtree(&mut self, task_id: &str)
pub fn cancel_subtree(&mut self, task_id: &str)
spc_002-06: recursively cancel task_id and every (recursive) child. Default cancellation
policy — no detached-child exemption yet (future card, per spc_002 §5).
Sourcepub fn cancel_children(&mut self, task_id: &str)
pub fn cancel_children(&mut self, task_id: &str)
spc_008-04: like Self::cancel_subtree but leaves task_id itself untouched — only its
(recursive) descendants are cancelled. For SupervisionPolicy.child_failure == ChildFailurePolicy::Propagate, where the terminating task’s own termination reason (set by
the caller) must not be overwritten by this call. Already-terminal children are skipped so a
child that already completed successfully is never retroactively relabeled as cancelled;
spc_008-05: a detached direct child is skipped too, same exemption cancel_subtree’s own
recursion honors — Propagate must not reach into a child that opted out of the lifecycle.
Sourcepub fn return_child_budget(&mut self, child_id: &str)
pub fn return_child_budget(&mut self, child_id: &str)
spc_005-05: return_unused a child’s budget_grant (if it has one) into its parent’s
child_budget_remaining, then record returned on the grant for audit. A no-op when the
child never carried a grant (spawned without requested_budget, or the parent had no
child_budget_remaining set — see spc_005-04) or when the parent has since lost its own
remaining-budget pool. Idempotent to call twice: the second call finds consumed already
reflecting the first return_unused’s inputs and returns the same (already-zeroed) delta —
callers still should call this exactly once per terminal transition.
Sourcepub fn send_message(&mut self, msg: MailboxMessage)
pub fn send_message(&mut self, msg: MailboxMessage)
spc_006-03: deliver msg into msg.to’s mailbox. A no-op (message silently dropped) when
to names no task in this table — mirrors get_mut’s own “absent id, no panic” contract
used throughout this table’s other mutators.
Sourcepub fn rebuild_children(&mut self)
pub fn rebuild_children(&mut self)
spc_002-09: recompute every task’s children set from the authoritative parent field.
insert only registers a child in its parent’s children when the parent is already
present in the table (spc_002-05) — a bulk restore that inserts rows in an order other
than parent-before-child silently drops those edges. This is idempotent and safe to call
after any bulk load.
Sourcepub fn rebuild_wait_index(&mut self)
pub fn rebuild_wait_index(&mut self)
Reinsert each task’s unsatisfied durable wait conditions after checkpoint restore.