Commit Graph

134 Commits

Author SHA1 Message Date
Alex Martini
7ee720bfc4 Use verb fragment, per API reference style 2025-03-27 16:51:25 -07:00
Konrad `ktoso` Malawski
fda7f539fb Reapply "Task names" (#79562) (#79600) 2025-03-08 10:58:49 +09:00
Konrad `ktoso` Malawski
f55964df26 [Concurrency] Initial steps for startSynchronously for Task (#79608)
* [Concurrency] Initial steps for startSynchronously for Task

* [Concurrency] Rename to _startSynchronously while in development

* [Concurrency] StartSynchronously special executor to avoid switching

* startSynchronously bring back more info output

* [Concurrency] startSynchronously with more custom executor tests

* add missing ABI additions to test for x86

* [Concurrency] gyb generate _startSynchronously

* [Concurrency] %import dispatch for Linux startSynchronously test

* [Concurrency] Add TaskGroup.startTaskSynchronously funcs

* [Concurrency] DispatchSerialQueue does not exist on linux still
2025-02-27 02:34:33 -08:00
Doug Gregor
177d16ced8 Enable strict memory safety in the Concurrency module 2025-02-26 14:28:24 -08:00
Konrad `ktoso` Malawski
09003d6f11 Revert "Merge pull request #77609 from ktoso/wip-task-names" (#79562)
This reverts commit 4ab5d2604f.
2025-02-23 22:59:21 -08:00
Konrad `ktoso` Malawski
4ab5d2604f Merge pull request #77609 from ktoso/wip-task-names
[Concurrency] Task names
2025-02-21 22:28:33 +09:00
Kuba (Brecka) Mracek
341d6305ff Merge pull request #76767 from kubamracek/embedded-concurrency-task-groups
[Concurrency] Enable TaskGroup/DiscardingTaskGroup in Embedded Swift
2024-10-03 19:29:54 -07:00
Kuba Mracek
7e00fe4b36 [embedded] Use hasFeature(Embedded) instead of in TaskGroup.swift+DiscardingTaskGroup.swift 2024-10-01 15:00:53 -07:00
Kuba Mracek
9b56ea03d2 [Concurrency] Drop the cloned code for Embedded around 'any actor' 2024-09-30 10:30:09 -07:00
Kuba Mracek
f1c2334c9a [Concurrency] Enable TaskGroup/DiscardingTaskGroup in Embedded Swift 2024-09-28 17:52:05 -07:00
Allan Shortlidge
ba3cd79b6f Concurrency: Remove superflous _SwiftConcurrencyShims imports.
The `_SwiftConcurrencyShims` module was imported `@_implementationOnly` which
was causing warnings to be emitted during the stdlib build. The module
currently serves no purpose; the only declaration it contains is a defunct
`_SwiftContext` struct which is not referenced by anything. The module needs to
continue to exist for source compatibility, though, since it is part of the
toolchain and imported publicly from other modules.
2024-09-09 12:20:13 -07:00
Alex Martini
906efcbe93 Merge pull request #75625 from amartini51/param_132944086
Match parameter names in documentation to declaration

Fixes: rdar://132944086
2024-08-08 09:22:11 -07:00
Richard L Zarth III
e2c9541537 Allow TaskGroup's ChildTaskResult Type To Be Inferred (#74517)
Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
2024-08-07 11:11:33 +09:00
Alex Martini
63323e04a9 Match parameter names in docs to the declaration 2024-08-01 11:01:02 -07:00
Alex Martini
736be735e6 DOCS: Add missing periods (#75407)
* Add missing period at end of sentence

* Add missing period

Co-authored-by: LamTrinh.Dev <me@lamtrinh.dev>

---------

Co-authored-by: LamTrinh.Dev <me@lamtrinh.dev>
2024-07-23 22:12:10 -07:00
Doug Gregor
d6b6bafe60 Extend _unsafeInheritExecutor_ to remaining @_unsafeInheritExecutor APIs
Extend the _unsafeInheritExecutor_ workaround to all remaining APIs in the
Concurrency library that have adopted `#isolation` default arguments to
(safely) stay in the caller's isolation domain...

... except one. Clock.measure() is currently running into problems with
the type checker workaround and needs a little more thought.

Fixes rdar://131760111.
2024-07-15 14:12:36 -07: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
Konrad `ktoso` Malawski
0c65fe8f42 Remove TaskGroup backDeployed annotation typo that included * (#74756)
Fix typo on a single task group backDeployed annotation.
2024-06-26 18:17:43 -07:00
Konrad `ktoso` Malawski
0160fc367a [Concurrency] adopt #isolation in last remaining APIs 2024-06-24 11:44:44 +09:00
Konrad `ktoso` Malawski
58c5a76836 [Concurrency] TaskGroup.with... APIs using #isolation
move tests to existing actor_withCancellationHandler.swift file
2024-06-24 11:44:44 +09:00
Michael Gottesman
d28eef2d62 [sending] Convert the TaskGroup APIs 2024-06-21 06:11:17 -07:00
Doug Gregor
c5a77fcce5 Add a proper TaskGroup.Iterator.next(isolation:)
Implement this function to pass the isolation through to the task group's
`next(isolation:)`. Fixes rdar://129690995.
2024-06-12 15:57:40 -07:00
Konrad `ktoso` Malawski
f245ecf45c [TaskGroup] Fix typo in code snippet 2024-06-10 18:29:38 +09: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
Konrad `ktoso` Malawski
3295ddd200 [Concurrency] waitForAll and next of TaskGroups must inherit isolation (#72794) 2024-04-04 23:49:05 -07:00
Allan Shortlidge
590d3353e6 Frontend: Introduce an alias for the IsolatedAny experimental feature.
To preserve compatibility with older compilers that do not allow `IsolatedAny`
to be enabled in production compilers, use an alias experimental feature when
building the stdlib (`IsolatedAny2`).

Also, add `@_allowFeatureSuppression(IsolatedAny)` in a couple spots it was
forgotten.

Partially resolves rdar://125138945
2024-03-27 22:20:50 -07: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
Mishal Shah
af112c1591 Update the Swift version to 6.0 from 5.11 2024-02-19 17:47:16 -08:00
Doug Gregor
a4f0709c2f Rename AsyncIteratorProtocol.next(_:) to next(isolation:)
Match the name of the method as specified in SE-0421
2024-02-09 14:18:37 -08:00
Doug Gregor
6ebb0ff560 Replace AsyncIteratorProtocol.nextElement() with isolated next(_:)
Use an optional isolated parameter to this new `next(_:)` overload to
keep it on the same actor as the caller, and pass `#isolation` when
desugaring the async for..in loop. This keeps async iteration loops on
the same actor, allowing non-Sendable values to be used with many
async sequences.
2024-01-25 16:04:48 -08:00
Doug Gregor
3e726ebc55 Add nextElement() and explicit Failure types for a number of asynchronous iterators 2024-01-25 16:04:44 -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
Konrad `ktoso` Malawski
0a2defed98 [Concurrency] Fix code snippet on task group docs
Code snippet was missing required of: parameter.
2023-06-24 10:59:13 +09:00
Konrad `ktoso` Malawski
d82de55ae4 less code duplication 2023-05-24 18:46:57 +02:00
Konrad `ktoso` Malawski
5fbdd8197d Minor mistake in group docs comment cocs snippet
We say in a comment here that we print the error and cancel, but we don't actually have the print below. This PR adds that missing print in the docs snippet.
2023-03-08 22:56:09 +09:00
Konrad `ktoso` Malawski
be4caa5b93 [Docs][Concurrency] Fix documentation about cancellation, copy docs to a few methods (#63960) 2023-02-28 17:32:15 +09:00
Konrad `ktoso` Malawski
3ffb3397a3 [Docs][Concurrency] TaskGroup docs: waitForAll (non-)cancellation (#63956) 2023-02-28 17:31:41 +09:00
Konrad `ktoso` Malawski
99fb37f678 [Concurrency] Fix too optimistic TaskGroup bail-out-when-empty, (#63016)
* [Concurrency] Fix too optimistic bail-out-when-empty, discarding group
may need to emit an error out of such waitAll attempt, if a previous
error was already stored.

* [Concurrency] DiscardingTG error thrown from body always wins

* Offering body error must be done while holding lock

* Must not modify waitingTask context outside lock

* wip on trying to fix by changing the offer

* fix bug in resuming tasks in offer/resume task in discarding group

* Fix #63147 waitForAll impl in ThrowingTaskGroup, used to not wait enough

rdar://104507347

* done

* debug

* explicitly declare virtual destructors

* detach child task after filling result; dont mutate context outside of lock

* Add pending count overflow protection to TaskGroup

* unlock async_taskgroup_void_neverConsumingTasks again rdar://104332560

* missing include on windows for error reporting

* fix ARM_ARCH_7K workaround snippet
2023-01-27 19:00:26 +09:00
Konrad `ktoso` Malawski
60ee652695 more docs 2023-01-05 16:19:06 +09:00
Konrad `ktoso` Malawski
7ac5b407a6 move to DiscardingTaskGroup 2023-01-05 16:19:05 +09:00
Konrad `ktoso` Malawski
ce8aacef98 fix abi 2023-01-05 16:19:05 +09:00
Konrad `ktoso` Malawski
2652862229 prepare for cancellation handling 2023-01-05 16:19:05 +09:00
Konrad `ktoso` Malawski
54dec38a34 initial complete impl 2023-01-05 16:19:05 +09:00
Konrad `ktoso` Malawski
f8b85015c1 prepare flags
wip on options

implement discardResults as a flag passed to grout init
2023-01-05 16:19:05 +09:00
Konrad `ktoso` Malawski
1a3403524c [Concurrency] Optimize Void task group, to not store completed tasks anymore 2023-01-05 16:19:05 +09: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