Commit Graph

24 Commits

Author SHA1 Message Date
Alastair Houghton
47fa71787f Revert "Merge pull request #80224 from glessard/revert-79789-custom-executors"
This reverts commit 06f6358067, reversing
changes made to 033f6679e8.
2025-03-28 10:15:07 +00:00
Alastair Houghton
8b15b05c63 Revert "[Concurrency] Provide a Swift interface for custom main and global executors." 2025-03-22 02:38:11 -07:00
Alastair Houghton
c20aa667f2 [Concurrency] Disable various things for task-to-thread model.
When in task-to-thread model concurrency mode, there is no `MainActor`
and we cannot use `ExecutorJob`, so disable various things.

rdar://141348916
2025-03-19 11:15:00 +00:00
Alastair Houghton
ef0e09d0b7 [Concurrency][Embedded] Remove MainActor/MainExecutor everywhere.
Embedded Swift doesn't have MainActor, so remove it.

rdar://141348916
2025-03-13 13:37:43 +00:00
Alastair Houghton
090c375b7b [Concurrency] Swift interface for custom main and global executors.
Reorganise the Concurrency code so that it's possible to completely
implement executors (both main and global) in Swift.

Provide API to choose the desired executors for your application.

Also make `Task.Sleep` wait using the current executor, not the global
executor, and expose APIs on `Clock` to allow for conversion between
time bases.

rdar://141348916
2025-03-13 13:34:41 +00:00
Doug Gregor
177d16ced8 Enable strict memory safety in the Concurrency module 2025-02-26 14:28:24 -08:00
Kuba Mracek
ed441eb1bf [Concurrency] Include more pieces of Concurrency in Embedded (AsyncStream, continuations)
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.
2024-10-02 09:22:36 -07:00
Allan Shortlidge
20d97556ae stdlib: Remove #if $TypedThrows guards.
https://github.com/swiftlang/swift/pull/72612 can be reverted because it is no
longer necessary for the interface of the stdlib to be compatible with
compilers without `$TypedThrows` support.
2024-07-08 16:52:52 -07:00
Allan Shortlidge
b47b5ccba0 Concurrency: Remove superfluous $BuiltinBuildMainExecutor guards. 2024-07-02 22:59:28 -07:00
Michael Gottesman
cf93476d0b [region-isolation] Require T in assumeIsolated<T> to be Sendable.
I had to change the APIs to always be always emit into client instead of back
deployable since silgen_name seems to interfere with @backDeployment. So I
switched the implementation so that it instead uses an always emit into client
thunk with the in source function name and a usableFromInline function that has
the silgen_name. This ensures that we still appropriately export the same symbol
as we did before, so it is ABI stable.

This was approved as part of se-0414.

rdar://122030520
2024-04-02 13:49:13 -07:00
Allan Shortlidge
65c0ef830e Concurrency: Guard use of withoutActuallyEscaping() in inlinable code.
Since `withoutActuallyEscaping()` has adopted typed throws, it's no longer
visible to older compilers that do not support typed throws. We need to guard
use of the function in inlinable code to make sure the textual interface of
`_Concurrency` remains buildable with older compilers.

Resolves rdar://124352900
2024-03-12 10:34:57 -07:00
Konrad `ktoso` Malawski
70b1c0e43c [Concurrency] Major cleanup of assert/precondition/assume isolated docs (#70800)
Co-authored-by: Alex Martini <amartini@apple.com>
2024-01-10 23:48:32 -08:00
Doug Gregor
0fbbc6ae65 [SE-0392] Back-deploy assertIsolation/assumeIsolation
The assertIsolation/assumeIsolation operations on actors are
back-deployable back to the introduction of concurrency. Do so.

Resolves rdar://111880539
2023-12-14 15:13:46 -08:00
Konrad `ktoso` Malawski
b8780c9d9e [Executors] Move assert/assume APIs onto actors; assumeIsolated() (#64812) 2023-04-04 07:44:43 +09:00
Nate Chandler
68eea8adec [TaskToThread] No unstructured tasks.
In this mode, the following are disabled:

- task creation
- global actors
- MainActor
- custom executors
2022-07-06 11:51:16 -07:00
Jager-yoo
3b8db192a0 [Gardening] fix typo "supercede" -> "supersede" 2022-05-29 03:35:24 +09:00
Karoy Lorentey
47956908b7 [Concurrency] SwiftStdlib 5.5 ⟹ SwiftStdlib 5.1 (usages)
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.
2021-10-28 14:36:36 -07:00
Doug Gregor
420e21a287 Fix the other implementation, too. 2021-10-22 08:39:22 -07:00
Doug Gregor
2850b65bd9 Simplify implementation and fix a test 2021-10-22 08:30:50 -07:00
Doug Gregor
5f9721c7fb Ensure that we hop off the main actor after MainActor.run.
Asynchronous functions isolated to global actors hop to the global at
the beginning of the function but do not hop back on return. For
`MainActor.run`, this means that we would not "hop back" off the main
actor after executing the closure, which lead to too much code running
on the main thread. Dropping the "async" ensures that we hop back.
While we my also want the general "hop back" semantics for
asynchronous actor-isolated functions, for now this addresses the
problem with `MainActor.run`.

Fixes rdar://82138050.
2021-10-21 23:26:02 -07:00
Doug Gregor
b2a902796c Force the mangled name of MainActor.run to not include the Sendable constraint.
This API already shipped without the Sendable constraint, and adding the
constraint (while it's fine with the compiler) changed the mangled name of
this API. Use `@_silgen_name` to restore the old existing mangled name so
we don't break the ABI.

Fixes rdar://83644760.
2021-09-29 09:25:22 -07:00
Doug Gregor
4a63884026 Add missing Sendable requirements and a conformance 2021-08-26 10:56:48 -07:00
John McCall
ca62a79079 Use &_dispatch_main_q as the identity of the main actor.
I added Builtin.buildMainActorExecutor before, but because I never
implemented it correctly in IRGen, it's not okay to use it on old
versions, so I had to introduce a new feature only for it.

The shim dispatch queue class in the Concurrency runtime is rather
awful, but I couldn't think of a reasonable alternative without
just entirely hard-coding the witness table in the runtime.
It's not ABI, at least.
2021-06-17 05:04:30 -04:00
Doug Gregor
8a068e0c08 [SE-0316] Introduce the GlobalActor protocol to describe global actors.
Based on the discussion in the first review of the global actors
proposal, introduce a `GlobalActor` protocol that describes types that
can be global actors. Introduce this protocol, make `@globalActor`
types implicitly conform to it, and remove all of the bespoke
validation logic that was used to check the "shared" member.

Addresses rdar://79339591
2021-06-15 06:39:12 -07:00