Commit Graph

1608 Commits

Author SHA1 Message Date
Evan Wilde
e88e947272 Merge pull request #62712 from etcwilde/ewilde/zipping-zippers-zip
Add zippering support
2023-01-03 21:45:33 -08:00
Kuba (Brecka) Mracek
e9d1d3096a Stop using SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY under SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY (#62735)
Using single-threaded concurrency was a temporary solution, now that the task-to-thread model actually supports multiple threads, let's switch off of it. Instead, let's introduce a "global executor none" option (implicitly set under the task-to-thread model) to denote that the concurrency model is not using a global executor.

rdar://99448771
2023-01-03 15:24:57 -08:00
Evan Wilde
f8a54181a9 Zipper all the things!
This patch goes through and adds zippering and the swift module
dependencies to a bunch of pieces of the swift runtimes. Here's to
hoping I hit everything that needed to be hit. :D

With this patch, I'm seeing the appropriate modules under
lib/swift/maccatalyst, so things seem to be working right.
2022-12-22 13:41:59 -08:00
Alex Martini
45aea1e2e1 Merge pull request #62685 from Jager-yoo/fix-concurrency-doc
[stdlib] Correct actual print outputs in Concurrency files
2022-12-22 09:25:35 -08:00
Rokhini Prabhu
28493d01be Merge pull request #62716 from apple/eng/PR-103426321-mutex-initialization
[Task-to-Thread] Make sure to explicitly initialize the drainLock in DefaultActorImpl::initialize
2022-12-21 09:15:55 -08:00
Rokhini Prabhu
1ba0462c27 [Task-to-Thread] Make sure to explicitly initialize the drainLock in
DefaultActorImpl::initialize or we could end up waiting on a garbage
lock value

Radar-Id: rdar://problem/103426321
2022-12-20 16:47:48 -08:00
Jager-yoo
9b2b8b3a49 [stdlib] Correct actual print outputs in Concurrency files 2022-12-19 23:40:03 +09:00
Saleem Abdulrasool
db21566651 Merge pull request #62432 from mhjacobson/freebsd-implement-clock-functions
Concurrency: implement clock functions for FreeBSD
2022-12-18 09:25:40 -08:00
PriyaAvhad
5d0a509d7b Merge pull request #62435 from PriyaAvhad/pavhad/86100601-stealer-support-for-actor-runtime
Stealer support for actor runtime.
2022-12-16 00:37:07 +05:30
Konrad `ktoso` Malawski
387d36242d [Concurrency] Fix missing inherit executor on withTaskCancellationHandler (#62546) 2022-12-13 21:45:11 +09:00
Konrad `ktoso` Malawski
f9c2bc0402 Apply suggestions from code review
Co-authored-by: Doug Gregor <dgregor@apple.com>
2022-12-13 10:39:46 +09:00
Konrad `ktoso` Malawski
342ce7ea19 cleaning up attributes 2022-12-12 12:02:31 +09:00
Konrad `ktoso` Malawski
d122fd68fa add _backDeploy and availability necessary for it 2022-12-09 17:46:34 +09:00
Konrad `ktoso` Malawski
b3c335798d Better fix, using inheriting executor 2022-12-09 10:22:48 +09:00
Konrad `ktoso` Malawski
2178d9893f [Concurrency] tasklocal withValue inside actor is safe 2022-12-09 10:22:47 +09:00
Priya Avhad
d792c07fdc Stealer support for actor runtime. 2022-12-07 21:04:45 +05:30
Matt Jacobson
da855ce116 Concurrency: implement clock functions for FreeBSD
Match OpenBSD in both swift_get_time and swift_get_clock_res.
2022-12-07 02:34:59 -05:00
Erik Eckstein
525550644c concurrency runtime: fix unused variable/label warnings 2022-11-21 19:50:39 +01:00
Matt Zanchelli
1a570e2b99 Correct grammar in documentation for AsyncStream.Continuation.finish() 2022-11-18 18:09:05 -08:00
Erik Eckstein
77fd3a7004 runtime: fix a wrong fall-through caused by an assert(false)
Replace the `assert(false)` with `swift_unreachable`.
This is more robust in release builds where the `assert(false)` is a no-op and would result in a wrong fall-though to the next switch case.
Fixes a warning in release builds.
2022-11-14 20:40:56 +01:00
swift-ci
627dc1f69c Merge pull request #61911 from apple/rokhinip/99977665-continuations-support
Implement continuations in task-to-thread model.
2022-11-09 20:16:14 -08:00
Rokhini Prabhu
b2f51dd3de Implement continuations in task-to-thread model.
This is done using a condition variable upon which the awaiting thread
will block if the continuation has not be resumed by the point of await.
The resuming thread will signal this condition variable, thereby
unblocking the awaiting thread.

Rdar://99977665
2022-11-09 15:58:53 -08:00
Saleem Abdulrasool
a066a6ecfb Concurrency: support newer dispatch functionality on Windows
This addresses an unintended instance where new dispatch functionality
is not used on Windows as the lookup was never performed.  This limits
the runtime to shared linking which should generally be a safe
assumption on Windows.
2022-11-04 06:56:46 -07:00
John McCall
7f737d235d Synchronize with cancellation when removing a task from a task group
We were detaching the child by just modifying the list, but the cancellation path was assuming that that would not be done without holding the task status lock.

This patch just fixes the current runtime; the back-deployment side is complicated.

Fixes rdar://88398824
2022-10-29 00:10:28 -04:00
Nate Chandler
c574550073 [Freestanding] Removed bridging intrinsic. 2022-10-18 11:27:21 -07:00
Nate Chandler
c9d86eed75 [Freestanding] Disable child task priority spec.
Under the task-to-thread model, specifying a priority doesn't make
sense.

Here, variations of addTask and addTaskUnlessCancelled are introduced
which do not take a priority.  Additionally, the original functions are
made unavailable.
2022-10-18 11:25:10 -07:00
Nate Chandler
fa82280337 [Freestanding] Disable AsyncStream. 2022-10-18 11:25:10 -07:00
Nate Chandler
cbaa1b14c8 [Freestanding] Disable Task.sleep. 2022-10-18 11:25:10 -07:00
Mike Ash
96e965a359 [Concurrency] Use dispatch cooperative queues when available.
These queues are better suited to the concurrency runtime.
2022-09-29 15:46:35 -04:00
swift-ci
77903dece6 Merge pull request #61065 from apple/rokhinip/92348139-actors-as-locks
[Freestanding] In the task-to-thread model, actors should behave like actual locks
2022-09-21 15:32:15 -07:00
swift-ci
b28efc557d Merge pull request #61117 from apple/revert-60790-rdar99047747
Revert "[Freestanding] Disable checked continuations."
2022-09-21 11:06:49 -07:00
swift-ci
d93c022125 Merge pull request #61076 from mikeash/unsafe-continuation-validation
[Concurrency] Add an environment variable to validate unchecked continuation usage.
2022-09-16 18:27:22 -07:00
Mike Ash
afc5116ef0 [Concurrency] Add an environment variable to validate unchecked continuation usage.
When enabled, we track all active unchecked continuations in a global set, and fatal error if one is called twice.

rdar://97390481
2022-09-16 13:50:59 -04:00
Mike Ash
2a5d6a950b Merge pull request #61054 from mikeash/tsan-fix-task-cancellation
[Concurrency] Fix memory ordering around task cancellation.
2022-09-15 10:38:03 -04:00
Rokhini Prabhu
ab16a647d8 [Freestanding] In a task-to-thread model where we don't have the means
to create extra threads to process jobs, actors should really behave
like locks.
2022-09-14 18:33:54 -07:00
nate-chandler
9a7c0b9869 Revert "[Freestanding] Disable checked continuations." 2022-09-14 17:29:49 -07:00
Mike Ash
9c849e431c [Concurrency] Fix memory ordering around task cancellation.
Load task status with an acquire when canceling a task, to synchronize with the store-release that comes when updating a task's status.

Add explicit TSan calls in cancellation, as well as withStatusRecordLock and addStatusRecord, to avoid TSan complaining about data races when canceling a task.

Add a test that checks for TSan-reported data races when canceling a task.

rdar://93892417
2022-09-14 13:39:55 -04:00
Egor Zhdan
84a1ffcb33 [Shims] Include SwiftShims headers without ../
This replaces a number of `#include`-s like this:
```
#include "../../../stdlib/public/SwiftShims/Visibility.h"
```
with this:
```
#include "swift/shims/Visibility.h"
```

This is needed to allow SwiftCompilerSources to use C++ headers which include SwiftShims headers. Currently trying to do that results in errors:
```
swift/swift/include/swift/Demangling/../../../stdlib/public/SwiftShims/module.modulemap:1:8: error: redefinition of module 'SwiftShims'
module SwiftShims {
       ^
Builds.noindex/swift/swift/bootstrapping0/lib/swift/shims/module.modulemap:1:8: note: previously defined here
module SwiftShims {
       ^
```
This happens because the headers in both the source dir and the build dir refer to SwiftShims headers by relative path, and both the source root and the build root contain SwiftShims headers (which are equivalent, but since they are located in different dirs, Clang treats them as different modules).
2022-09-14 11:14:50 +01:00
Rokhini Prabhu
4c0f88bdee Move isDistributedRemote out of ActiveActorStatus since it does not need
to be modified in the atomic - it is set once and never changed again
2022-09-13 13:15:26 -07:00
Rokhini Prabhu
76e7cb1cd0 Merge pull request #60860 from apple/rokhinip/92347604-run-task-upon-await
[Freestanding] Only run tasks when they are awaited up on in task-to-thread model
2022-09-01 15:18:06 -07:00
Rokhini Prabhu
a606892155 Task group children should be executed on parent task at time of await 2022-09-01 10:02:25 -07:00
Rokhini Prabhu
cb6ffe831b In task-to-thread model, make sure that when we are waiting on an
async-let task, we run it in the context of the parent task.
2022-09-01 10:02:25 -07:00
Rokhini Prabhu
f2099c50cd Make sure that current thread's priority propagates to a runInline task 2022-09-01 10:02:25 -07:00
nate-chandler
1f38c4bb3b Merge pull request #60790 from nate-chandler/rdar99047747
[Freestanding] Disable checked continuations.
2022-08-31 07:39:21 -07:00
Nate Chandler
c20bd86007 [Freestanding] Disable checked continuations.
In the task-to-thread model, there are no threading mechanisms by which
work could be offloaded onto another thread.  As such, callback based
asynchronous APIs which are not Swift async do not make sense.

rdar://99047747
2022-08-25 16:55:45 -07:00
Alex Martini
8556e8337a Merge pull request #60178 from amartini51/doc_fixes
Documentation fixes
2022-08-24 13:53:24 -07:00
Doug Gregor
c42025a571 Merge pull request #60661 from DougGregor/concurrency-api-sendable-fixes
[Concurrency] Fix a few annotations for the concurrency library
2022-08-19 16:47:32 -07:00
Doug Gregor
ee4f6b1f75 Make CheckedContinuation and UnsafeContinuation unconditionally Sendable.
The continuation types were conditionally `Sendable` based on whether
the result type of the continuation was `Sendable`. However,
conceptually, the return value is never leaving the current task, so
it is never actually crossing concurrency boundaries. Therefore, we
can make the continuation types unconditionally `Sendable`.

Fixes rdar://98462858.
2022-08-19 13:06:41 -07:00
Doug Gregor
cf9a7478c3 Apply @_unsafeInheritExecutor to with(Throwing)TaskGroup.
Fixes rdar://98461630.
2022-08-19 13:06:41 -07:00
Konrad `ktoso` Malawski
ecccce6113 [Concurrency] Deprecate one of the cancellation handler overloads (#60569) 2022-08-18 11:14:30 +09:00