Commit Graph

15 Commits

Author SHA1 Message Date
Alastair Houghton
d6224d16d9 [Concurrency] Fix minimal stdlib build again.
Some mentions of `ExecutorJob` were not guarded by the required
`SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY` condition.
2025-08-26 09:38:14 +01:00
Alastair Houghton
6046286b58 [Concurrency] Updates after second SE pitch.
We no longer attempt to convert timestamps from the passed-in `Clock`
in order to allow any clock to work with any executor.  Instead,
executors that do not recognise a clock should call the `enqueue`
function on that `Clock`, which lets the `Clock` itself decide how
to proceed.

Additionally, rename `SchedulableExecutor` to `SchedulingExecutor`.
2025-08-26 09:38:11 +01:00
Alastair Houghton
a55008066d [Concurrency] Further improve performance.
Remove some reference counting traffic by using `Unowned*Executor`s.

Also, add a test to make sure we stay on the fast path.

rdar://156701386
2025-07-30 13:41:04 +01:00
Alastair Houghton
69a2011f4f [Concurrency] Fix null pointer dereference for task-to-thread model.
In task-to-thread concurrency mode, `_getMainExecutorAsSerialExecutor`
returns `SerialExecutorRef::generic()`, which is, give or take, NULL.
Unfortunately we'd declared it as returning `any SerialExecutor`,
rather than `(any SerialExecutor)?`, and then the `getMainExecutor()`
function was calling `asUnownedSerialExecutor()` on it, which then
crashes.

rdar://153152063
2025-06-12 11:36:16 +01:00
Alastair Houghton
28732f4a8b Revert "[Concurrency] Add underscore prefixes for not yet official API." 2025-05-20 15:44:26 +01:00
Alastair Houghton
c0ccdffeb7 [Concurrency] Add underscore prefixes for not yet official API.
Custom main and global executors work hasn't passed Swift Evolution yet,
so we need to avoid leaking it as API until it does.

To that end, underscore all the things.

rdar://151147606
2025-05-14 11:57:06 +01:00
Alastair Houghton
a418ce4931 [Concurrency] Fix some comments and a typo.
There were a couple of comments that needed updating, and a typo
in a function name.

rdar://141348916
2025-03-28 10:15:14 +00:00
Alastair Houghton
0c96a257f6 [Concurrency] Fix task-to-thread model linking.
We need to provide some of the additional functions, as stubs, for
task-to-thread model.

rdar://141348916
2025-03-28 10:15:14 +00:00
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
444bbd5b00 [Concurrency] Update following pitch comments.
Remove `supportsScheduling` in favour of a type-based approach.

Update the storage for `ClockTraits` to `UInt32`.

Adjust ordering of executors for `currentExecutor`.

rdar://141348916
2025-03-13 13:37:43 +00:00
Alastair Houghton
fc67cc3b60 [Concurrency] Mark expressions as unsafe.
Also fix a missing availability annotation.

rdar://141348916
2025-03-13 13:37:43 +00:00
Alastair Houghton
55afa47bea [Concurrency] More work on the custom executor implementation.
Added an `-executor-factory` argument to the compiler to let you safely
specify the executors you wish to use (by naming a type that returns
them).

Also added some tests of the new functionality.

rdar://141348916
2025-03-13 13:34:41 +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