Commit Graph

259 Commits

Author SHA1 Message Date
Harlan Haskins
a721ef63f6 Un-deprecate Task.startOnMainActor (#75544) 2024-08-16 06:36:18 +09:00
Allan Shortlidge
fb6ab05746 Concurrency: Restore -enable-experimental-feature IsolatedAny.
Supported older compilers don't enable this feature by default, so it can't be
omitted from the `_Concurrency` module's flags (regression from
https://github.com/swiftlang/swift/pull/74543).

Additionally, remove `@_allowFeatureSuppression(IsolatedAny)` from all
declarations. We no longer need to support compilers that don't have the
`IsolatedAny` feature, so the suppression is superfluous and the alternative
branches didn't actually build anyways. _Additionally_, the suppressible
feature logic could not handle suppressing `IsolatedAny` simultaneously with
`SendingArgsAndResults`, resulting in a broken interface because `sending` was
used outside `#if $SendingArgsAndResults` guards.
2024-07-03 10:36:47 -07:00
Allan Shortlidge
346bbcaa05 Concurrency: Remove superfluous $BuiltinCreateAsyncTaskInGroup guards. 2024-07-02 22:26:55 -07:00
Allan Shortlidge
ee8a1152b2 Concurrency: Promote BuiltinCreateTask feature to baseline. 2024-07-02 22:26:55 -07:00
Michael Gottesman
d28eef2d62 [sending] Convert the TaskGroup APIs 2024-06-21 06:11:17 -07:00
Michael Gottesman
b541e0299e [concurrency] Deprecate some source compatibility APIs in swift 5 and obsolete in swift 6.
These APIs remained to preserve source compatibility during bringup. We do not
want them used in swift 6 mode... so deprecate in swift 5 and obsolete in swift
6.
2024-06-21 02:24:03 -07:00
Michael Gottesman
4697546e09 [sending] Mark Task.init,detached, and friends as sending methods instead of __owned @Sendable so we can capture non-isolated values. 2024-06-21 02:24:03 -07: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
Konrad `ktoso` Malawski
89adc8293c [Docs] Minor rewording of Task docs, easier to read 2024-06-04 15:42:04 +09:00
John McCall
a86b76a3e9 Use @isolated(any) function types for task functions.
The biggest annoyance here is having to clone all of the task creation
functions for Embedded Swift because it can't use `any Actor` right now.
2024-03-15 14:40:54 -04:00
Holly Borla
5d9ad87a82 [Concurrency] Task executors are available in Swift 6.0. 2024-03-13 09:56:24 -07:00
Ian Anderson
288f37b2c1 [Concurrency] [shims] Don't declare exit in the concurrency shims
Don't delete the OS declaration of `exit` because the concurrency shims aren't always imported, and so the shim declaration might not always be available.
Don't override the OS declaration of `exit` in the concurrency shims since we can't just delete the OS one. Instead, set up internal shims just for building Concurrency that forward declares `exit`.
2024-01-29 16:25:46 -08:00
Konrad `ktoso` Malawski
828f589be4 Initial Task Executor implementation Task(on:), addTask(on:) etc. (#68793)
Co-authored-by: John McCall <rjmccall@gmail.com>
2023-12-12 17:14:24 +09:00
Choo Hyun Ho
630d4306b5 correct typos in Concurrency/Task.swift 2023-11-16 20:45:20 +09:00
Kuba Mracek
90e1d2006f [embedded] Add support for actors and async let into the embedded Concurrency runtime 2023-10-09 22:43:50 -07:00
Kuba Mracek
5d8c55eacb [embedded] Initial Swift Concurrency for embedded Swift 2023-10-06 20:04:03 -07:00
Konrad `ktoso` Malawski
911f0f9787 update wording 2023-09-13 12:37:56 +09:00
Konrad `ktoso` Malawski
906d89fb81 Update stdlib/public/Concurrency/Task.swift
Co-authored-by: Alex Martini <amartini@apple.com>
2023-09-13 12:18:40 +09:00
Konrad `ktoso` Malawski
52ab95f2db Update stdlib/public/Concurrency/Task.swift
Co-authored-by: Alex Martini <amartini@apple.com>
2023-09-13 11:33:42 +09:00
Konrad `ktoso` Malawski
d45d56bfbd Update stdlib/public/Concurrency/Task.swift
Co-authored-by: Alex Martini <amartini@apple.com>
2023-09-13 11:33:32 +09:00
Konrad `ktoso` Malawski
11b6bd0396 better example 2023-09-12 21:34:50 +09:00
Konrad `ktoso` Malawski
1e7e5181ab Document more explicitly closure lifetime of a Task init 2023-09-12 21:02:28 +09:00
Yuta Saito
97ac3985e2 [Concurrency] Fix signature mismatch of _startTaskOnMainActor
The function is defined in Task.cpp with a void return type, but
referenced in Task.swift with an pointer return type.
2023-06-11 12:29:11 +00:00
Konrad `ktoso` Malawski
d82de55ae4 less code duplication 2023-05-24 18:46:57 +02:00
Konrad `ktoso` Malawski
cad608eb81 [Discarding] Don't leak retained "first error" task when retaining it 2023-05-24 18:03:28 +02:00
Evan Wilde
ad81f8d557 Allow discarding startOnMainActor results
Adding discardableResult to startOnMainActor
2023-04-18 16:40:54 -07:00
Kavon Farvardin
f40d90f885 fix another unguarded use of MainActor 2023-03-08 14:12:13 -08:00
Evan Wilde
f8e1272097 Concurrency: appease the api-digester
Looks like simply putting the availability attribute on the extension
does not suffice. Putting the availability attr on the function itself
to appease the api-digester.
2023-03-06 13:33:22 -08:00
Evan Wilde
1bd1c468a0 Concurrency: Task.startOnMainActor
This patch adds an SPI to run the first partial function of a MainActor
asynchronous function on the MainActor synchronously. This is
effectively like the asynchronous program entrypoint behavior. The first
partial function is run synchronously. Following continuations are
enqueued for execution like any other asynchronous function.
2023-03-06 13:33:22 -08:00
Konrad `ktoso` Malawski
a2783b2e8d [Concurrency] UnownedJob.priority and description for TaskPriority 2023-02-28 16:17:48 +09:00
Konrad `ktoso` Malawski
5431c6dad3 [Concurrency] Base priority should be present on UnsafeTask too (#63563) 2023-02-22 15:56:50 +09:00
Rokhini Prabhu
e052ccef31 Create the notion of a TaskDependencyStatusRecord which tracks what a
task is blocked on. We can use this information to then perform live
priority escalation to a task future.

Radar-Id: rdar://problem/88093007
2023-02-08 17:29:55 -08:00
Nate Chandler
c574550073 [Freestanding] Removed bridging intrinsic. 2022-10-18 11:27:21 -07:00
Nate Chandler
34c08b8344 [TaskToThread] Add Task.runInline.
The new intrinsic, exposed via static functions on Task<T, Never> and
Task<T, Error> (rethrowing), begins an asynchronous context within a
synchronous caller's context.  This is only available for use under the
task-to-thread concurrency model, and even then only under SPI.
2022-07-08 08:44:18 -07:00
Nate Chandler
68eea8adec [TaskToThread] No unstructured tasks.
In this mode, the following are disabled:

- task creation
- global actors
- MainActor
- custom executors
2022-07-06 11:51:16 -07:00
Evan Wilde
9ab7a822df Cleaning up _runAsyncMain a bit
I'm making two cleanups here. First, the closure going into
`_runAsyncMain` needs to be `@Sendable` or passing it to the task is not
safe. This will also result in a warning being emitted.
Second, I'm making this @usableFromInline and `internal`. This function
is around for legacy reasons, but it's part of the ABI, so we can't pull
it out entirely, but we don't want folks using it.
2022-03-21 13:02:20 -07:00
Hamish Knight
a2cfbda850 Revert "Cleaning up _runAsyncMain a bit" 2022-03-05 13:14:36 +00:00
Evan Wilde
b6414b383b Merge branch 'main' into ewilde/concurrency/cleanup-run-async-main 2022-02-17 16:08:17 -08:00
Philippe Hausler
e675b310f8 [SE-0329] Clock/Instant/Duration (#40609)
* [WIP] Initial draft at v2 Clock/Instant/Duration

* Ensure the literal types for _DoubleWide are able to be at least 64 bits on 32 bit platforms

* static cast timespec members to long

* Remove runtime exports from clock functions

* Export clock functions in implementations as they are in headers

* Clean up internal properties by adding leading underscores, refine availability to a TBD marker macro, and break at 80 lines to match style

* Shift operators to concrete Instant types to avoid complexity in solver resolution

* Adjust diagnostic note and error expectation of ambiguities to reflect new potential solver (perhaps incorrect) solutions

* Update stdlib/public/Concurrency/TaskSleep.swift

Co-authored-by: Karoy Lorentey <klorentey@apple.com>

* [stdlib][NFC] Remove trailing whitespace

* [stdlib] Remove _DoubleWidth from stdlib's ABI

* [stdlib] Strip downd _DoubleWidth to _[U]Int128

* Additional adjustments to diagnostic notes and errors expectation of ambiguities to reflect new potential solver (perhaps incorrect) solutions

* Disable type checker performance validation for operator overload inferences (rdar://33958047)

* Decorate Duration, DurationProtocol, Instant and clocks with @available(SwiftStdlib 9999, *)

* Restore diagnostic ambiguity test assertion (due to availability)

* Add a rough attempt at implementing time accessors on win32

* Remove unused clock id, rename SPI for swift clock ids and correct a few more missing availabilities

* remove obsolete case of realtime clock for dispatch after callout

* Use the default implementation of ~ for Int128 and UInt128

* Ensure diagnostic ambiguitiy applies evenly to all platforms and their resolved types

* Restore the simd vector build modifications (merge damage)

* Update to latest naming results for Instant.Duration

* Updates to latest proposal initializers and accessors and adjust encoding/decoding to string based serialization

* Update availability for Clock/Instant/Duration methods and types to be 5.7

* Correct *Clock.now to report via the correct runtime API

* Ensure the hashing of Duration is based upon the attoseconds hashing

* Avoid string based encoding and resort back to high and low bit encoding/decoding but as unkeyed

* Adjust naming of component initializer to use suffixes on parameters

* Duration decoding should use a mutable container for decoding

* fix up components initializer and decode access

* Add platform base initializers for timespec and tiemval to and from Duration

* Add some first draft documentation for standard library types Duration, DurationProtocol and InstantProtocol

* Another round of documentation prose and some drive-by availability fixes

* InstantProtocol availability should be 5.7

* Correct linux timeval creation to be Int and not Int32

Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2022-02-17 09:32:46 -08:00
Konrad `ktoso` Malawski
083afff45a Update stdlib/public/Concurrency/Task.swift
Co-authored-by: Alex Martini <amartini@apple.com>
2022-02-10 10:54:16 +09:00
Konrad `ktoso` Malawski
6691dcff81 Update stdlib/public/Concurrency/Task.swift
Co-authored-by: Kavon Farvardin <kfarvardin@apple.com>
2022-02-04 06:57:19 +09:00
Konrad `ktoso` Malawski
259c37c4ca [Concurrency] Fix docs which suggested outdated patterns; can't store "current" task safely 2022-02-03 20:57:37 +09:00
Ole Begemann
b32ae80e0c Remove Task.CancellationError in doc comments
Task.CancellationError has been renamed to CancellationError. Fix two doc comments that still used the old name.
2022-01-30 20:17:36 +01:00
Karoy Lorentey
61268aa259 [stdlib] Define placeholder version numbers for SwiftStdlib 5.7
Also update existing declarations with SwiftStdlib 9999 availability to use the 5.7 name.
2022-01-27 14:41:07 -08:00
Rokhini Prabhu
9df1c9a135 Track base priority separately from max priority whereby base priority
is set at creation time. Create a new API for accessing this state

Radar-Id: rdar://problem/86100376
2022-01-24 07:50:27 -08:00
Rokhini Prabhu
8f2ac188fb Make sure that currentPriority actually reads the max QoS in the active
task status instead of the Job priority which is not necessarily in sync

Radar-Id: rdar://problem/86100376
2022-01-21 12:12:12 -08:00
Evan Wilde
bfcc809ac8 Merge branch 'main' into ewilde/concurrency/cleanup-run-async-main 2022-01-03 08:36:40 -08:00
Evan Wilde
1f198bcd93 Cleaning up _runAsyncMain a bit
I'm making two cleanups here. First, the closure going into
`_runAsyncMain` needs to be `@Sendable` or passing it to the task is not
safe. This will also result in a warning being emitted.
Second, I'm making this @usableFromInline and `internal`. This function
is around for legacy reasons, but it's part of the ABI, so we can't pull
it out entirely, but we don't want folks using it.
2021-12-21 11:42:09 -08:00