Commit Graph

1638 Commits

Author SHA1 Message Date
Konrad `ktoso` Malawski
fe86091cc1 Merge pull request #82558 from ktoso/wip-cleanup-group-docs 2025-07-08 01:06:51 -07:00
Pavel Yaskevich
2b05dc630b Merge pull request #82833 from xedin/remove-startSynchronously
[Concurrency] Remove deprecated `Task.startSynchronously` API
2025-07-07 16:47:15 -07:00
Alastair Houghton
79f746e62d [Concurrency] Don't use ExecutorJob for task-to-thread model.
Task-to-thread model doesn't have `ExecutorJob`, so we can't use it;
however, we probably also don't need `_swift_createJobForTestingOnly`
there so just `#if` it out in that case.

rdar://155054460
2025-07-07 11:43:53 +01:00
Pavel Yaskevich
e108524d98 [Concurrency] Remove deprecated Task.startSynchronously API
This is the original spelling which was not accepted. We kept
it for a bit to give adopters time to switch but it's time to
remove it now.
2025-07-07 00:31:19 -07:00
Alastair Houghton
57d056e1a3 Merge pull request #82457 from al45tair/external-executor-test-support
[Concurrency] Add functions to allow testing of external executors.
2025-07-04 09:52:57 +01:00
Konrad `ktoso` Malawski
ec8caf3cdd Remove the experimental @Task macro (#82437) 2025-07-03 10:15:21 -07:00
Doug Gregor
bfb62e1262 Don't implement swift_task_deinitOnExecutorMainActorBackDeploy in the task-to-thread model 2025-07-01 16:06:05 -07:00
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
Doug Gregor
f736677022 Switch to the appropriate C calling convention for pthread_main_np 2025-07-01 08:15:54 -07:00
Doug Gregor
7789a0ce64 [SE-0371] Back-deploy support for main-actor-isolated deinit
When targeting a platform that predates the introduction of isolated
deinit, make a narrow exception that allows main-actor-isolated deinit
to work through a special, inlineable entrypoint that is
back-deployed. This implementation

  1. Calls into the real implementation when available, otherwise
  2. Checks if we're on the main thread, destroying immediately when
we are, otherwise
  3. Creates a new task on the main actor to handle destruction.

This implementation is less efficient than the implementation in the
runtime, but allows us to back-deploy this functionality as far back
as concurrency goes.

Fixes rdar://151029118.
2025-06-30 17:38:08 -07:00
Alastair Houghton
f2c820a35c Merge pull request #82563 from al45tair/eng/PR-154346018
[Concurrency] Prevent negative sleeps from sleeping forever.
2025-06-30 17:45:36 +01:00
Konrad `ktoso` Malawski
396379ecbf Merge pull request #82227 from ktoso/wip-deprecate-extractisolation 2025-06-30 20:32:30 +09:00
Alastair Houghton
80791035a3 [Concurrency] Prevent negative sleeps from sleeping forever.
Requests to sleep until a negative timestamp would result in sleeping
until `UINT64_MAX` nanoseconds from the start of the relevant clock,
which is about 585 years.

rdar://154346018
2025-06-27 11:15:05 +01:00
Alastair Houghton
f7f4a19baf Merge pull request #82417 from al45tair/eng/PR-153531418
[Concurrency] Rename Dummy(Main|Task)Executor.
2025-06-26 10:53:57 +01:00
Konrad `ktoso` Malawski
989ec93762 Merge branch 'main' into wip-deprecate-extractisolation 2025-06-25 16:57:52 +09:00
Alastair Houghton
0d14682f99 [Concurrency] Rename Dummy(Main|Task)Executor.
`UnimplementedExecutor` seems like a better name.

rdar://153531418
2025-06-23 16:47:50 +01:00
Konrad 'ktoso' Malawski
57a6a9931a [Concurrency] Task.immediate returning Never error must not have throwing operation
rdar://153855920
2025-06-20 09:32:37 +09:00
Konrad `ktoso` Malawski
1ea746ec52 Merge branch 'main' into wip-deprecate-extractisolation 2025-06-16 11:37:19 +09:00
Mike Ash
ec6a042831 [Runtime] Remove redundant swift_auth_code_function, use existing swift_auth_code.
rdar://153169049
2025-06-13 18:46:23 -04:00
Konrad 'ktoso' Malawski
c00946189c [Concurrency] Deprecate extractIsolation 2025-06-13 11:47:37 +09: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
Dan Blackwell
665515c781 Merge pull request #82158 from swiftlang/tsan-release-fix
[concurrency] Move tsan_release to point before task gets destroyed
2025-06-12 08:26:49 +01:00
Konrad `ktoso` Malawski
01f911a36b Merge pull request #82179 from ktoso/wip-fix-incorrect-memory-effects-on-task-create 2025-06-12 13:42:32 +09:00
Konrad 'ktoso' Malawski
3aa28b4de9 [Concurrency] Correct memory effect attributes of task_create
Without this, llvm would sometimes wrongly assume there's no indirect
accesses and the optimizations can lead to a runtime crash, by
optimizing away initializing options properly.

Resolves rdar://152548190
2025-06-11 22:03:52 +09:00
Philippe Hausler
af76f1440c Convert DispatchGlobalExecutor deadline casts to a decltype based cast (which should hold on all platforms) 2025-06-10 22:11:05 -07:00
Dan Blackwell
100a4e096c [concurrency] Move tsan_release to point before task gets destroyed
rdar://152501929
2025-06-10 19:35:46 +01:00
Philippe Hausler
1e0b9148df static cast the tv_sec for the timespec constructions is the dispatch scheduler 2025-06-10 09:11:10 -07:00
Philippe Hausler
694aebb1fb Add an additional case for clocks to sleep with a wallclock deadline (#79139)
This only modifies the runtime function `swift_task_enqueueGlobalWithDeadline` to take new clock primitive to
interoperate with existing dispatch wall clock values.
2025-06-09 09:01:27 -07:00
Alastair Houghton
42ca1b1cc8 Rename SwiftStdlibCurrentOS to StdlibDeploymentTarget.
`StdlibDeploymentTarget` seems to be a better name.

rdar://152498657
2025-06-04 10:40:19 +01:00
Alastair Houghton
d5ed335339 Merge pull request #81440 from al45tair/currentos-availability
[Concurrency][Stdlib] Add SwiftStdlibCurrentOS availability, use it.
2025-06-03 15:01:22 +01:00
Konrad 'ktoso' Malawski
7305efabdd [Concurrency] Prefer swift_auth_code_function over swift_auth_code
This allows us to use constants, and not hardcoded numbers
2025-06-03 06:59:42 +09:00
Konrad 'ktoso' Malawski
2c99a669d3 Correct priority cancellation handler signing once more
Resolves rdar://150378890 for real this time, verified on arm64e myself
2025-06-02 21:32:57 +09:00
Pavel Yaskevich
f586af422c Merge pull request #81817 from xedin/fix-startSynchronously-to-use-old-symbol
[Concurrent] Restore old symbol for obsoleted `Task.startSynchronously`
2025-05-29 17:20:11 -07:00
Mike Ash
5be22fa7cc [Concurrency] Fix races/overflows in TaskGroup implementation.
statusCompletePendingReadyWaiting(), offer(), and poll() did a one-off compare_exchange_strong which could fail if the group was concurrently cancelled. Put these into loops so that they are retried when needed.

DiscardingTaskGroup creation passed the group result type as the task result type. waitAll() would then use the group result type when collecting task results. Since the task result type is always Void in this case, this would overflow the result buffer if the group result type was larger. This often works as it writes into the free space of the task allocator, but can crash if it happens to be at the end of a page or the group result type is particularly large.

rdar://151663730
2025-05-28 20:58:33 -04:00
Pavel Yaskevich
5059f81da0 [Concurrent] Restored old symbol for obsoleted Task.startSynchronously
https://github.com/swiftlang/swift/pull/80821 added `@isolated(any)`
which is an ABI breaking change but since we are not planning to keep
this API around, let's use `@_silgen_name` to bring the old name back
for now.

Resolves: rdar://152178221
2025-05-28 14:27:02 -07:00
Konrad `ktoso` Malawski
31b6ae2fcf Merge pull request #80984 from ktoso/task-names-update
[Concurrency][SE-review update] Task names update
2025-05-28 06:23:49 +09:00
Konrad 'ktoso' Malawski
97a4904c1f [Concurrency] Correct the signing of priority escalation handler 2025-05-23 17:02:19 -07:00
Alastair Houghton
cd7701cd82 [Build] Add catalyst support to SwiftStdlibCurrentOS.
Add catalyst support for SwiftStdlibCurrentOS.

Also, set a minimum deployment target when building Concurrency;
this stops the build failing when we're trying to build on older
systems where Concurrency didn't really exist yet.

rdar://150966361
2025-05-23 10:31:56 +01:00
Alastair Houghton
3305e89ff9 Merge pull request #81639 from swiftlang/revert-81472-eng/PR-151147606
Revert "[Concurrency] Add underscore prefixes for not yet official API."
2025-05-22 15:36:52 +01:00
Pavel Yaskevich
a64984af45 Merge pull request #81572 from xedin/adopt-inheritActorContextAlways-in-Task-APIs
[stdlib] Adopt `@_inheritActorContext(always)` on `Task.immediate`
2025-05-20 09:05:35 -07:00
Alastair Houghton
28732f4a8b Revert "[Concurrency] Add underscore prefixes for not yet official API." 2025-05-20 15:44:26 +01:00
Pavel Yaskevich
0598b8c9f4 [stdlib] Task.immediate annotate operation parameter with @_implicitSelfCapture
Since the "operation" inherits the context of the actor it should
also be possible to reference its members without explicit use of
`self.`.
2025-05-19 18:01:23 -07:00
Pavel Yaskevich
8c05636e28 [stdlib] Concurrency: Add @_alwaysEmitIntoClient to add Task.*immediate* 2025-05-19 18:01:07 -07:00
Allan Shortlidge
a85caaf296 Concurrency: Address new -strict-memory-safety warnings. 2025-05-18 10:37:19 -07:00
Pavel Yaskevich
c3c1b4fca0 [stdlib] Adopt @_inheritActorContext(always) on Task.immediate
This change aligns implementation with the current SE-0472 proposal.
2025-05-16 14:27:46 -07:00
Alastair Houghton
7f97e8d10b Merge pull request #81472 from al45tair/eng/PR-151147606
[Concurrency] Add underscore prefixes for not yet official API.
2025-05-15 18:39:21 +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
Saleem Abdulrasool
cab1f40218 Concurrency: silence warning on Windows
Prefer `strncpy_s` over `strncpy` which triggers a warning. This
function ensures that the copied string is null-terminated if the string
fits or simply returns an empty string (`\0`) if the string does not
fit. Prefer to use `_TRUNCATE` to copy as much of the name as fits and
ensure that it is null-terminated.
2025-05-13 09:48:33 -07:00
Alastair Houghton
485b8f6888 Merge pull request #81446 from al45tair/eng/PR-150531873
[Concurrency] Remove deprecation attribute for now.
2025-05-12 20:02:03 +01:00
Alastair Houghton
c6d1969afc [Concurrency] Remove deprecation attribute for now.
This deprecation attribute is possibly a little premature.

rdar://150531873
2025-05-12 15:35:45 +01:00