Commit Graph

1223 Commits

Author SHA1 Message Date
Konrad `ktoso` Malawski
f245ecf45c [TaskGroup] Fix typo in code snippet 2024-06-10 18:29:38 +09:00
Konrad `ktoso` Malawski
0135623d9a [docs] fix typo in type name in code snippet 2024-06-10 17:21:47 +09:00
Konrad `ktoso` Malawski
d8cba034b3 [docs] remove swift style code highlighting on non-swift snippet 2024-06-10 17:20:57 +09:00
Konrad `ktoso` Malawski
cd0b3f0d4d [docs] Remove line in Task docs that is an error in Swift 6 mode 2024-06-10 17:19:57 +09:00
Alex Lorenz
c8b5344d3e Merge pull request #72014 from compnerd/android
utils: support building android SDKs on Windows
2024-06-07 12:37:00 -07:00
Michael Gottesman
db66a207e1 Merge pull request #74151 from gottesmm/pr-89c1f2ab73ad928c312b9bdddb9e2c5cb550439c
[concurrency] Update withUnsafe{,Throwing}Continuation to have a sending result.
2024-06-05 20:06:09 -07:00
Alex Lorenz
5aa63fc93e Merge pull request #72634 from hyp/eng/android/ndk-overlay
[android] add an Android NDK Swift overlay
2024-06-05 19:35:13 -07:00
Michael Gottesman
5db3b70c65 [concurrency] Update withUnsafe{,Throwing}Continuation to have a sending result.
rdar://129299180
2024-06-05 12:50:59 -07:00
Konrad `ktoso` Malawski
4fc0f3ab61 Merge pull request #73634 from ktoso/wip-document-exexecutors-apidoc 2024-06-05 06:27:46 +09:00
Konrad `ktoso` Malawski
89adc8293c [Docs] Minor rewording of Task docs, easier to read 2024-06-04 15:42:04 +09:00
Konrad `ktoso` Malawski
2182dce8b7 [Concurrency] Document custom executors in API docs a bit
Include review feedback and show how to customize a single actor by
passing an executor through initializer
2024-06-04 15:42:02 +09:00
Konrad `ktoso` Malawski
083fdaa0de Merge pull request #73998 from nickolas-pohilets/mpokhylets/fix-32-build 2024-06-04 13:49:19 +09:00
Konrad `ktoso` Malawski
14b8546392 [Concurrency] Don't add new task locals copy runtime func 2024-06-03 13:55:02 +09:00
Michael Gottesman
ce1dd43395 [sending] Change CheckedContinuation/AsyncThrowingStream.Continuation APIs to use sending parameters and results.
Specifically:

1. CheckedContinuation.resume now takes a sending parameter.
2. Async{Throwing,}Stream.yield takes a sending parameter.
3. withCheckedContinuation returns a transferring parameter.

Importantly due to the previous changes around mangling, this is a mangling
neutral change.

rdar://120420024
2024-06-01 23:25:16 -07:00
Konrad `ktoso` Malawski
0c44645832 [Concurrency] Implement defensive copying in task groups, rather than crashing (#73978) 2024-05-31 11:27:03 -07:00
Mykola Pokhylets
987b641a7c Updated HeaderFooterLayout to correctly handle empty Header or Footer 2024-05-30 21:56:28 +02:00
Mykola Pokhylets
a891b8f0fb Move isDistributedRemoteActor outside #if 2024-05-30 21:55:58 +02:00
Mike Ash
7427aa5f48 [Concurrency] Remove SWIFT_ENABLE_ASYNC_JOB_DISPATCH_INTEGRATION environment variable.
This option serves no purpose anymore and this dispatch integration should always be enabled.
2024-05-30 12:43:19 -04:00
Holly Borla
135e3f2ee9 Merge pull request #73889 from hborla/deprecate-anyactor
[Concurrency] Deprecate `AnyActor`.
2024-05-30 09:36:35 -07:00
Mykola Pokhylets
b5e039d1e0 Fixed 32-bit build with SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION 2024-05-30 13:15:39 +02:00
Mykola Pokhylets
6298d41edf Reapply "Fix quadratic performance of the ListMerger in specific usage pattern"
This reverts commit 2640ff613b.
2024-05-30 13:08:42 +02:00
Holly Borla
c20b0e0956 [Concurrency] Obsolete AnyActor in Swift 6 using a typealias. 2024-05-29 22:59:19 -07:00
John McCall
a8d163bb23 Merge pull request #73966 from rjmccall/condvar-await-scope
Fix a bug with task-to-thread continuations
2024-05-29 18:56:51 -04:00
Mike Ash
d0ed6f6ba2 Merge pull request #73945 from mikeash/dispatch-async-swift-job-no-dlsym
[Concurrency] Reference dispatch_async_swift_job directly when the header is available.
2024-05-29 14:25:55 -04:00
John McCall
d3e7b5116f In the task-to-thread model of UnsafeContinuation, destroy the
condvar before we try to tail-call.  This is necessary because the
swiftasync tail-call handling is (reasonably) reluctant to reorder
cleanups so that locals are destroyed before the call, and of course it
cannot destroy them after it and still emit a tail call.

Old versions of clang handled these tailcalls differently and failed
to diagnose this, but I'm pretty sure they just ended up not doing a
tail call rather than actually doing anything reasonable.

Fixes rdar://125363169
2024-05-28 22:04:50 -04:00
Konrad `ktoso` Malawski
a664c02f60 Merge pull request #73934 from ktoso/pick-concurrency-isCurrent-more-fixes 2024-05-29 10:07:53 +09:00
Mike Ash
c396f75792 [Concurrency] Reference dispatch_async_swift_job directly when the header is available.
Only use dlsym when we don't have the header, since it's an unnecessary performance hit.

rdar://118465481
2024-05-28 17:35:39 -04:00
Alex Lorenz
57b89d5303 [android] add an android NDK Swift overlay module, and use it instead of Glibc 2024-05-28 12:57:38 -07:00
Konrad `ktoso` Malawski
7c0e1f599a [Concurrency] Fix embedded, cannot refer to runtime/env vars from Actor.cpp 2024-05-28 18:19:55 +09:00
Konrad `ktoso` Malawski
e9b25d1091 [Concurrency] Move innermost record assertion to handle more gracefully 2024-05-28 16:58:38 +09:00
Konrad `ktoso` Malawski
153806b71a [Concurrency] Reshape initial values of executor checking so tests pass on Linux 2024-05-27 17:02:26 +09:00
Konrad `ktoso` Malawski
d36f99540c [Concurrency] Always assume that if expecting main actor and are on main thread that this is equal 2024-05-27 17:02:26 +09:00
Konrad `ktoso` Malawski
7790609fc8 [Concurrency] Futher prevent crashes in legacy mode of isCurrentExecutor 2024-05-27 17:02:26 +09:00
Konrad `ktoso` Malawski
481c928d67 [Concurrency] Fix missing return in legacy isSameExecutor mode detection
resolves rdar://128425368
resolves rdar://127400013
2024-05-27 17:02:25 +09:00
Holly Borla
1011e4ddb0 [Concurrency] Only deprecate AnyActor, and update more tests.
Obsoleting `AnyActor` in Swift 6 blocks the Concurrency library itself
from migrating to Swift 6, because `Actor` and `DistributedActor` have to
preserve their refinement of `AnyActor` to avoid breaking code currently
using the marker protocol. There's no way to move protocol refinement into
an extension so that the use-site declaration can be obsoleted, so we're
stuck with just the deprecation of `AnyActor`.
2024-05-24 12:58:02 -07:00
Holly Borla
7af38860ed [Concurrency] Deprecate and obsolete AnyActor.
This marker protocol isn't useful for abstracting over actors and distributed
actors because it doesn't have any runtime requirements, so there's no way
to switch to the given actor. Instead, you should use `isolated (any Actor)?`
parameters, and the compiler will compute a local actor value from a
distributed actor using `DistributedActor.asLocalActor`.
2024-05-24 08:57:17 -07:00
Mike Ash
634295c85e Merge pull request #73796 from mikeash/fix-resume-function-for-logging
[Concurrency] Refine getResumeFunctionForLogging to avoid reading invalid future contexts.
2024-05-22 16:57:37 -04:00
Andrew Trick
2640ff613b Revert "Fix quadratic performance of the ListMerger in specific usage pattern" 2024-05-21 16:23:57 -07:00
Mike Ash
0f226b6667 [Concurrency] Refine getResumeFunctionForLogging to avoid reading invalid future contexts.
When using a future adapter, the resume context may not be valid after the task starts running. Only peer through the adapter when we're starting to run.

rdar://126298035
2024-05-21 16:22:40 -04:00
John McCall
e1a82f622e Merge pull request #70910 from nickolas-pohilets/mpokhylets/fix-list-merger-performance
Fix quadratic performance of the `ListMerger` in specific usage pattern
2024-05-20 17:26:34 -04:00
Mike Ash
dd24d8e71f [Runtime] Don't emit signposts until the system is ready.
Emitting a signpost for the first time can trigger lazy setup of the logging system, and doing this in the wrong context can cause deadlocks. Check to see if the logging system is already set up, and only emit signposts if it has been to avoid triggering this.

As it's hard to determine if the "is it set up?" function is available in the SDK we're building against, only do this in OS builds, as it's not particularly useful in local builds.

rdar://124620772
2024-05-15 11:02:23 -04:00
Kuba Mracek
fba653708e [embedded] Explicitly install the embedded concurrency .a libraries with +x permissions 2024-05-13 10:27:26 -07:00
Mykola Pokhylets
9ba09ff63d Process incoming queue when obtaining drainer lock 2024-05-10 11:05:22 +02:00
Mykola Pokhylets
40c38f9803 Using multiple insertion points to ensure all jobs are always inserted in O(1)
Fully separated unprocessed jobs and processed jobs
Reverse jobs after updating status to minimise contention
2024-05-10 11:05:22 +02:00
Mykola Pokhylets
21a70e10c7 Fixed quadratic performance of ListMerger when each executed job creates 2+ new jobs of the same priority
See https://forums.swift.org/t/quadratic-performance-of-the-listmerger-in-specific-use-case/69393
2024-05-10 11:05:22 +02:00
Konrad `ktoso` Malawski
b2bd17635f [Concurrency] Fix too eager early return in checkIsolation mode detecting (#73495) 2024-05-09 03:12:37 -07:00
Stephen Canon
da9922d8bb Avoid using generic static members on Duration across module boundaries (#73419)
* Avoid using generic static members on Duration across module boundaries

Because the clocks are implemented in Concurrency, but Duration is in the Swift module, these don't get specialized. Add a fully-concrete internal init in Concurrency to avoid the problem.

* Call self.init(_high:low:) explicitly.

* Add availability annotation.
2024-05-04 10:40:10 -04:00
Doug Gregor
406346b4ba Merge pull request #73425 from DougGregor/task-group-next-public 2024-05-04 00:09:28 -07:00
Doug Gregor
b8d6c7f9d2 Disfavor the older next() APIs on TaskGroup 2024-05-03 12:21:35 -07:00
Doug Gregor
f85eed4858 Bring back TaskGroup.next() and ThrowingTaskGroup.next() as public API
With the introduction of `next(isolation:)` into the task group types,
we removed the public APIs for the no-argument `next()` versions,
leaving them only as `@usableFromInline internal` entrypoints for the
ABI. Because the `next(isolation:)` versions have a default argument,
this was sufficient for providing source compatibility for calls, but
not for protocol conformances.

Bring these APIs back publicly. Fixes rdar://127499568.
2024-05-03 12:09:55 -07:00