I would like to have a Bool
returning API to support isolated deinit. Implementation of the isolated deinit uses swift_task_isCurrentExecutor()
to choose between fast path (no hopping) and slow path (hopping).
I wonder what are other examples of SerialExecutor
implementations, aside from the Dispatch
-based. Would they benefit from having var isIsolated: Bool?
in the SerialExecutor
protocol, even if Dispatch-based implementation just returns nil
?
But even for Dispatch
I see an opportunity. If code passes expected.checkIsolated()
check, then we could set Task.current.executor = expected
for the duration of the block passed to assumeIsolated()
. Then inside the block calls to swift_task_isCurrentExecutor(expected)
would return true
, enabling fast path of the isolated deinit.