Commit Graph

15 Commits

Author SHA1 Message Date
Alastair Houghton
26878c98de [Concurrency] Add functions to allow testing of external executors.
Added a couple of functions to allow for the testing of executors that
aren't implemented inside the concurrency runtime itself.

rdar://154195821
2025-07-01 16:48:03 +01:00
Alastair Houghton
e843a24a99 [Concurrency] Fix issue with using Dispatch queues as executors.
We were failing to switch executors to Dispatch queues, where those
were being used as executors, which caused a variety of unusual
symptoms.

rdar://150310927
2025-04-30 14:18:42 +01:00
Alastair Houghton
3d0d0b4328 [Concurrency] Make initial executor construction fully thread safe.
I had originally thought that we'd get away without this because the
executor construction generally happens in the async `main` function,
but of course if a program doesn't already use Swift Concurrency,
and someone uses it from a plug-in or library it loads, there's a
risk that we might have a race condition.

rdar://149346132
2025-04-17 21:48:42 +01:00
Max Desiatov
cb0e1da0cb Revert "Revert "Concurrency: Move code between Executor{Bridge,Impl}.cpp"" (#80692)
* Revert "Revert "Concurrency: Move code between `Executor{Bridge,Impl}.cpp`""

* Update CMakeLists.txt
2025-04-10 05:35:28 -07:00
Artem Chikin
ef6cf5785b Revert "Concurrency: Move code between Executor{Bridge,Impl}.cpp (#80601)"
This reverts commit ccd9cf7b5e.
2025-04-09 11:07:31 -07:00
Max Desiatov
ccd9cf7b5e Concurrency: Move code between Executor{Bridge,Impl}.cpp (#80601)
New `ExecutorImpl.cpp` is excluded when building Embedded Swift stdlib. This fixes duplicate symbol errors when using Embedded Swift.
2025-04-09 05:36:07 -07: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
ed08858998 [Concurrency] Fix availability.
Fix up availability after the non-Darwin changes.  Also update the
ABI baseline.

Fix a Win32 typo.

rdar://141348916
2025-03-17 16:24:06 +00:00
Alastair Houghton
a4f79f367a [Concurrency][Linux] Fix WASI build.
This doesn't actually add proper WASI support - it just fixes the
build so that we're no worse off than we were.

rdar://141348916
2025-03-14 14:57:15 +00:00
Alastair Houghton
b33666cf08 [Concurrency] Fixes from initial review.
Rename `DispatchTaskExecutor` to `DispatchGlobalTaskExecutor` as we
may want to use the former for an executor that runs things on an
arbitrary Dispatch queue.

Rename `DispatchExecutor` to `DispatchExecutorProtocol`; again, we
might want the name for something else.

Add `@Sendable` attribute to `registerEvent`.

Fix missing `extern "C" SWIFT_CC(swift)` on `_swift_exit` (merge
error).

Remove stray whitespace from `CMakeLists.txt`

rdar://141348916
2025-03-13 13:37:43 +00:00
Alastair Houghton
d14b9370fb [Concurrency] Don't use blocks.
We can't use blocks, because Swift doesn't support them on Linux or
Windows.  Instead, use a C function pointer, and box up the handler.

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