We have been only including a subset of files and functionality on Embedded Concurrency, let's instead include all the
source files, and have a fine grained opt out on things that don't yet work. Namely, this is still avoiding clocks, task
sleeping and custom executors.
Add a test for AsyncStream and continuations on Embedded Concurrency.
The move from `@_unsafeInheritExecutor` to `#isolation` for the
with*Continuation breaks code that is using `@_unsafeInheritExecutor` and
calling these APIs. This originally caused silent breakage (which manifest
as runtime crashes), and is now detected by the compiler as an error.
However, despite `@_unsafeInheritExecutor` being an unsafe,
not-intended-to-be-user-facing feature, it is indeed being used, along
with these APIs. Introduce _unsafeInheritExecutor_-prefixed versions of
the `with*Continuation` and `withTaskCancellationHandler` APIs into
the _Concurrency library that use `@_unsafeInheritExecutor`. Then,
teach the type checker to swap in these
_unsafeInheritExecutor_-prefixed versions in lieu of the originals
when they are called from an `@_unsafeInheritExecutor` function. This
allows existing code using `@_unsafeInheritExecutor` with these APIs
to continue working as it has before, albeit with a warning that
`@_unsafeInheritExecutor` has been removed.
Fixes rdar://131151376.
Specifically:
1. CheckedContinuation.resume now takes a sending parameter.
2. Async{Throwing,}Stream.yield takes a sending parameter.
3. withCheckedContinuation returns a transferring parameter.
Importantly due to the previous changes around mangling, this is a mangling
neutral change.
rdar://120420024
In the task-to-thread model, there are no threading mechanisms by which
work could be offloaded onto another thread. As such, callback based
asynchronous APIs which are not Swift async do not make sense.
rdar://99047747
The continuation types were conditionally `Sendable` based on whether
the result type of the continuation was `Sendable`. However,
conceptually, the return value is never leaving the current task, so
it is never actually crossing concurrency boundaries. Therefore, we
can make the continuation types unconditionally `Sendable`.
Fixes rdar://98462858.
Not inheriting the caller's executor is a major problem for
these functions. Under SE-0338, treating them as non-isolated
means that it's illegal to pass them anytthing non-Sendable
from a different isolation context; since the function is
declared to take a non-sendable function parameter, effectively,
SE-0338 means that these functions can only be safely called
from non-isolated contexts. That's not really acceptable, but
it gets worse: since we haven't implemented the sendability
rule for that yet, we're immediately bypassing isolation safety
when using these functions with no warning.
The `withCheckedContinuation` functions are not
`@_alwaysEmitIntoClient` (an oversight in the initial release),
and so we need to use the unsafe attribute on them. When we
eventually implement a safe mechanism for this, we should make
`@_alwaysEmitIntoClient` variants of these functions which use
the new feature, and we can demote the existing functions to
`internal @availableFromInline`.
I've gone ahead and made `withChecked*Continuation` `@inlinable`.
Make the continuation type's conformances to the `Sendable` protocol
conditional on the sendability of the result yielded when the
resumption is performed. This ensures that one cannot silently escape
a continuation's result out of a task or actor, closing a safety hole
in Sendable checking.
Fixes rdar://85419546.
The concurrency runtime now deploys back to macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, which corresponds to the 5.1 release of the stdlib.
Adjust macro usages accordingly.
This allows programs to target older OSes while using Concurrency behind an availability check. When targeting older OSes, the symbols are weak-linked and the compiler will require the use of Concurrency features to be guarded by an availability check.
rdar://75850003
The goal of doing this is to reduce the amount of boilerplate and repeated code w.r.t. Continuation. Having just added `resume()` in four places, I got the sense that there was a lot of common code that was being duplicated. I removed the Throwing variants of these types (they can be expressed as Continuation<T, E:Error> instead of ThrowingContinuation<E>) and I broke out a significant amount of common code between CheckedContinuation and UnsafeContinuation into an implementation-only protocol to avoid repeating it. D.R.Y.
This change resolves rdar://74154769.
This change implements the changes proposed in swift-evolution PR #1264.
Existing test coverage should be sufficient here since the added function
simply calls into the existing `resume(returning:)` function.
This change resolves rdar://74031110.
To help catch runtime issues adopting `withUnsafeContinuation`, such as callback-based APIs that misleadingly
invoke their callback multiple times and/or not at all, provide a couple of classes that can take ownership of
a fresh `UnsafeContinuation` or `UnsafeThrowingContinuation`, and log attempts to resume the continuation multiple times
or discard the object without ever resuming the continuation.