Commit Graph

20 Commits

Author SHA1 Message Date
Konrad 'ktoso' Malawski
80f384958a [Concurrency] Parent task cancellation must cancel task group itself.
Seems that during refactorings of child cancellations we somehow missed
also cancelling the group itself. It seems we did not have good test
coverage of the addTaskUnlessCancelled somehow and thus this slipped
through.

This adds a regression test for addTaskUnlessCancelled and fixes how we
handle the cancellation effect in TaskStatus.

resolves #80789
resolves rdar://149177600
2025-04-14 17:06:44 +09:00
Konrad `ktoso` Malawski
6f38910058 DiscardingTaskGroup now shares some implementation with "Accumulating" TaskGroup 2023-01-09 11:35:04 +09:00
John McCall
7f737d235d Synchronize with cancellation when removing a task from a task group
We were detaching the child by just modifying the list, but the cancellation path was assuming that that would not be done without holding the task status lock.

This patch just fixes the current runtime; the back-deployment side is complicated.

Fixes rdar://88398824
2022-10-29 00:10:28 -04:00
Rokhini Prabhu
835f274183 Make sure that cancelling a task group does not invoke cancellation
handler of parent task that created the group

Change comment in TaskGroup.swift to enforce that only parent task can
call cancelAll on the group

Add tests to verify mutating of task group in child tasks will fail

Radar-Id: rdar://problem/86346865
2021-12-17 18:35:39 -08:00
Rokhini Prabhu
4bcaa2e7d9 There is no inherent synchronization in the TaskGroupStatusRecord so
when a task is adding adding new children to a task group, we need to
synchronize with the task status record lock of the parent task that has the
task group, to prevent races with concurrent cancellation and escalation.

Radar-Id: rdar://problem/86311782
2021-12-10 20:17:24 -08:00
Konrad `ktoso` Malawski
dd10132b12 [Concurrency] Cancelled group should only spawn already cancelled tasks 2021-06-24 09:22:45 +09:00
Konrad `ktoso` Malawski
ba615029c7 [Concurrency] Store child record when async let child task spawned 2021-04-19 10:06:23 +09:00
John McCall
6c879d6fd3 Change the async ABI to not pass the active task and executor.
Most of the async runtime functions have been changed to not
expect the task and executor to be passed in.  When knowing the
task and executor is necessary, there are runtime functions
available to recover them.

The biggest change I had to make to a runtime function signature
was to swift_task_switch, which has been altered to expect to be
passed the context and resumption function instead of requiring
the caller to park the task.  This has the pleasant consequence
of allowing the implementation to very quickly turn around when
it recognizes that the current executor is satisfactory.  It does
mean that on arm64e we have to sign the continuation function
pointer as an argument and then potentially resign it when
assigning into the task's resume slot.

rdar://70546948
2021-03-16 22:52:54 -04:00
Konrad `ktoso` Malawski
aedbbe615d [TaskGroup] Towards ABI stability of groups 2021-03-02 20:25:22 +09:00
Konrad `ktoso` Malawski
d7169edc21 [TaskLocals] Cleanly separate locals impl from Task, no need for fragment 2021-03-02 00:54:47 +09:00
Konrad `ktoso` Malawski
1cb3000a7e [TaskGroup] group is not NativeObject, just an opqeue value 2021-02-26 16:03:30 +09:00
Konrad `ktoso` Malawski
cdd136096f reworked includes to stop hitting undefined symbols 2021-02-25 15:15:02 +09:00
Konrad `ktoso` Malawski
599572ba54 cleanups of tests after merge 2021-02-25 14:24:43 +09:00
Konrad `ktoso` Malawski
de5fdcd2f8 [TaskGroup] fix missing retain in scheduling next() immediately on offer 2021-02-24 18:45:33 +09:00
Konrad `ktoso` Malawski
655d8f13e7 cleanup after rebase; this is likely incorrect in some way 2021-02-24 12:10:49 +09:00
Konrad `ktoso` Malawski
b33fae8656 import dispatch in tests, so they can run on linux as well 2021-02-22 13:26:38 +09:00
Konrad `ktoso` Malawski
999758cc85 [Concurrency][TaskGroup] allow cancelAll be invoked from child tasks 2021-02-22 13:26:33 +09:00
Konrad `ktoso` Malawski
1c4655df6a [Concurrency] track child tasks from group in Task records 2021-02-22 13:26:33 +09:00
Konrad `ktoso` Malawski
a100424b4a getting there with assuming that poll is a single task 2021-02-22 13:26:27 +09:00
Konrad `ktoso` Malawski
a226259d84 [Concurrency] TaskGroup moves out of AsyncTask, non escaping body 2021-02-22 13:26:27 +09:00