Commit Graph

1656 Commits

Author SHA1 Message Date
Evan Wilde
48fb7cd874 Merge pull request #83087 from etcwilde/ewilde/op-precedence
Fix warning in DispatchGlobalExecutor
2025-07-17 00:41:02 -07:00
Yuta Saito
af85e061dd Merge pull request #83086 from kateinoigakukun/yt/fix-isolated-conformance-static-link 2025-07-17 08:35:52 +09:00
Konrad `ktoso` Malawski
197530d264 Merge pull request #82943 from ktoso/wip-remove-task-startsynchronously-symbol 2025-07-17 06:48:40 +09:00
Yuta Saito
30e0fa5133 [Concurrency] Fix runtime isolated-conformance checks with static stdlib
Most of linkers pull object files from static archives only if any
symbol from that object file is referenced, even if the object contains
a ctor code. `Setup.cpp` didn't have any symbols referenced from
other code, so it was not linked in when the concurrency runtime was
linked in statically. This commit moves the ctor code to `Task.cpp`
to ensure that it is always linked in.
2025-07-16 06:28:04 +00:00
Evan Wilde
38c3ac1d22 Fix warning in DispatchGlobalExecutor
Fixing "warning: '&&' within '||'" -Wlogical-op-parentheses warning
2025-07-15 20:00:32 -07:00
Saleem Abdulrasool
326f18d113 Runtimes: detect the existence of dispatch_async_swift_job
This function is used by the executor to help schedule the async job.
While not currently available on Windows on main, this allows correctly
handling the presence of the symbol for static linking.
2025-07-11 11:28:07 -07:00
Konrad `ktoso` Malawski
47db5ade76 [Concurrency] Align Task.isolated with proposal (add task executor) (#82913) 2025-07-11 08:42:19 +09:00
Saleem Abdulrasool
817922175d Merge pull request #82932 from compnerd/static-flags
utils: build static runtime with static dispatch and closure
2025-07-10 14:46:09 -07:00
Konrad 'ktoso' Malawski
5996da0c0c [Concurrency] Remove symbols of startSynchronously, make it AEIC
In preparation for removal. This spelling of Task.immediate was before
SE-review and was NOT accepted and therefore we should try to remove it
entirely.
2025-07-10 17:34:29 +09:00
Konrad 'ktoso' Malawski
664be9bd1e [Concurrency] Add missing Task.immediateDetached, which drops task locals 2025-07-10 14:57:44 +09:00
Konrad 'ktoso' Malawski
358c3e9dcf [Concurrency] a few missing overloads for immediate tasks 2025-07-10 12:40:41 +09:00
Saleem Abdulrasool
8b74c09b8f utils: build static runtime with static dispatch and closure
Although we would like these to be dynamic, we currently cannot build
them properly due to limitations of the build system. Adjust the build
to pass in additional flags to properly build the runtimes for that
environment as a temporary measure.
2025-07-09 14:41:59 -07:00
Pavel Yaskevich
72267bb1d4 Merge pull request #82892 from swiftlang/revert-82833-remove-startSynchronously
Revert "[Concurrency] Remove deprecated `Task.startSynchronously` API"
2025-07-09 00:19:08 -07:00
Alex Martini
74c3dbcd24 Revise doc comment for style & clarity
- Move the definition of 'structured concurrency' to the beginning of
  the section.
- Avoid future tense.  Fix some mixed future+present tense errors.
- Write bullet points as individual sentences, not as the clauses of one
  long sentence.
- Apple Style: Use 'since' only in the sense of 'after'.
- Apple Style: Use 'you' instead of 'one'.
- Apple Style: Close up 'non-' except when ambiguous.
- DevPubs style: Avoid bare 'this' for clarity.  Here, 'this guarantee'
  tells the reader what 'this' refers to.
- DevPubs style: Avoid 'may' which can be ambiguous between possibility
  and permission.
2025-07-08 14:31:29 -07:00
Pavel Yaskevich
8c4f7e97c8 Revert "[Concurrency] Remove deprecated Task.startSynchronously API" 2025-07-08 13:54:23 -07:00
Alex Martini
51b2033eeb Fix more 'cancel(l)ed' style issues 2025-07-08 10:50:43 -07:00
Alex Martini
4a7ac28bcb Remove stray spaces
These looks like the side effect of a find-and-replace for PR 82558
fixing 'cancelled' vs 'canceled'.
2025-07-08 10:45:36 -07:00
Changhyun Kang
bf61199e88 [Concurrency] fix documentation typos in TaskGroup.swift (#82291) 2025-07-08 21:02:19 +09:00
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