Skip to content

[Concurrency] Harden async_task_async_let_child_cancel so it does not need sleep #37108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func printWaitPrint(_ int: Int) async -> Int {

@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
func test() async {
let h = detach {
await printWaitPrint(0)
}

let handle = detach {
print("detached run, cancelled:\(Task.isCancelled)")

Expand All @@ -27,6 +31,8 @@ func test() async {
async let two = printWaitPrint(2)
print("spawned: 2")

h.cancel()

let first = await one
print("awaited: 1: \(first)")
let second = await two
Expand All @@ -40,7 +46,7 @@ func test() async {
print("exit detach")
}

await Task.sleep(2 * 1_000_000)
await h.get()

print("cancel")
handle.cancel()
Expand Down