Commit Graph

14 Commits

Author SHA1 Message Date
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
69c965e15c [Concurrency] Don't pass negative times to the Dispatch code.
Dispatch uses unsigned times, and cannot cope with times before its
clock started.  As such, passing negative times from Swift through to
the C++ code results in large unsigned values, which then causes us to
wait forever.  This is undesirable.

rdar://148899609
2025-05-06 15:56:07 +01:00
Alastair Houghton
5b5f486a31 [Concurrency] Use the correct Dispatch clock.
This caused a hard-to-reproduce bug where a machine that had slept for
a long time would take a very long time to run some of the tests because
we'd be scheduling Dispatch executions with the wrong clock.

rdar://148337712
2025-04-01 16:07:12 +01: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
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
00e7ef2d21 [Concurrency] Remove EventableExecutor, alter asSchedulable.
EventableExecutor is being removed, for now, but hopefully will
return in some form in the future.

The `asSchedulable` implementation needs to change for reasons of
ABI stability.

rdar://141348916
2025-03-13 13:37:43 +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
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
d89ea190bb [Concurrency] Add clock traits.
Remove the hacky support for mapping clocks to a Dispatch clock ID,
in favour of clocks publishing traits and having the Dispatch
executor select the clock on the basis of those traits.
2025-03-13 13:34:41 +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