mirror of
https://github.com/apple/swift.git
synced 2026-02-27 18:26:24 +01:00
This is the minimal set of changes from https://github.com/swiftlang/swift/pull/80753 to specifically address the with...Continuation APIs re-enqueueing tasks when they need not have to. Resolves rdar://162192512 --- Before, 10 enqueues in total in the task executor case: ``` 1: === foo() async 2: --------------------------------------- 3: [executor][task-executor] Enqueue (1) 4: foo - withTaskExecutorPreference 5: [executor][task-executor] Enqueue (2) 6: foo - withTaskExecutorPreference - withCheckedContinuation 7: [executor][task-executor] Enqueue (3) 8: foo - withTaskExecutorPreference - withCheckedContinuation done 9: [executor][task-executor] Enqueue (4) 10: foo - withTaskExecutorPreference - withUnsafeContinuation 11: [executor][task-executor] Enqueue (5) 12: foo - withTaskExecutorPreference - withUnsafeContinuation done 13: [executor][task-executor] Enqueue (6) 14: foo - withTaskExecutorPreference - withCheckedThrowingContinuation 15: [executor][task-executor] Enqueue (7) 16: foo - withTaskExecutorPreference - withCheckedThrowingContinuation done 17: [executor][task-executor] Enqueue (8) 18: foo - withTaskExecutorPreference - withUnsafeThrowingContinuation 19: [executor][task-executor] Enqueue (9) 20: foo - withTaskExecutorPreference - withUnsafeThrowingContinuation done 21: [executor][task-executor] Enqueue (10) 22: foo - withTaskExecutorPreference done 23: == Make: actor Foo 24: --------------------------------------- 25: [executor][actor-executor] Enqueue (1) 26: actor.foo 27: actor.foo - withCheckedContinuation 28: actor.foo - withCheckedContinuation done 29: actor.foo - withUnsafeContinuation 30: actor.foo - withUnsafeContinuation done 31: actor.foo - withCheckedThrowingContinuation 32: actor.foo - withCheckedThrowingContinuation done 33: actor.foo - withUnsafeThrowingContinuation 34: actor.foo - withUnsafeThrowingContinuation done 35: actor.foo done 36: done ``` After, two total enqueues in the task executor: ``` 1: === foo() async 2: --------------------------------------- 3: [executor][task-executor] Enqueue (1) 4: foo - withTaskExecutorPreference 5: foo - withTaskExecutorPreference - withCheckedContinuation 6: foo - withTaskExecutorPreference - withCheckedContinuation done 7: foo - withTaskExecutorPreference - withUnsafeContinuation 8: foo - withTaskExecutorPreference - withUnsafeContinuation done 9: foo - withTaskExecutorPreference - withCheckedThrowingContinuation 10: foo - withTaskExecutorPreference - withCheckedThrowingContinuation done 11: foo - withTaskExecutorPreference - withUnsafeThrowingContinuation 12: foo - withTaskExecutorPreference - withUnsafeThrowingContinuation done 13: [executor][task-executor] Enqueue (2) 14: foo - withTaskExecutorPreference done 15: == Make: actor Foo 16: --------------------------------------- 17: [executor][actor-executor] Enqueue (1) 18: actor.foo 19: actor.foo - withCheckedContinuation 20: actor.foo - withCheckedContinuation done 21: actor.foo - withUnsafeContinuation 22: actor.foo - withUnsafeContinuation done 23: actor.foo - withCheckedThrowingContinuation 24: actor.foo - withCheckedThrowingContinuation done 25: actor.foo - withUnsafeThrowingContinuation 26: actor.foo - withUnsafeThrowingContinuation done 27: actor.foo done 28: done ```