[Concurrency] Inherit parent's deadlines into structured child tasks
Structured children (async let, task groups) run within the same
deadline scope as their parent, so Task.hasActiveDeadline and
Task.activeDeadline(for:) should observe the same deadlines on the
child that the parent would.
Implementation: swift_task_create_common calls a new
AsyncTask::inheritDeadlinesFrom(parent) helper right after the
parent-cancellation-propagation block. The helper snapshots the
parent's deadline records under its status-record lock, then pushes
copies onto the child (retaining each record's _ClockBox<C>). The
push happens through addStatusRecord so the child's HasDeadline flag
is set naturally.
Ordering: parent records are collected innermost-first; the child's
chain is built by pushing them in reverse so the child's chain
matches the parent's exactly. This preserves the 'innermost = tightest'
invariant the runtime relies on to make
swift_task_findNearestDeadlineForClock's single-walk answer correct.
Cleanup: ~AsyncTask calls a new cleanupInheritedDeadlines() that
walks the residual chain and swift_releases each deadline record's
box. Inherited records never go through the user-visible push/pop
pair, so without this the retains would leak. The record memory
itself lives in the task's slab allocator and is torn down by
Private.destroy(), so we don't individually dealloc them.
Detached tasks do NOT inherit deadlines - they aren't structured
children of the enclosing withDeadline scope. This is the correct
behavior: an unstructured task escapes its creator's lifetime.
Runtime tests in with_deadline_basic.swift:
- test_async_let_inherits_deadline: async let sees parent's deadline
- test_task_group_child_inherits_deadline: TaskGroup child sees it too
- test_detached_task_does_not_inherit_deadline: Task.detached does not
- test_nested_deadlines_inherited_correctly: child inside a nested
scope sees the inner (tighter) deadline, not the outer
Also updates test_custom_clock_deadline_subsumption and
test_outer_deadline_subsumes_inner_no_scope to use the new
_findNearestDeadline return type (C.Instant? instead of the old
_DeadlineComponents tuple). Concurrency dylib builds cleanly.