Commit Graph

44 Commits

Author SHA1 Message Date
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
Konrad `ktoso` Malawski
fe86091cc1 Merge pull request #82558 from ktoso/wip-cleanup-group-docs 2025-07-08 01:06:51 -07:00
Mike Ash
5be22fa7cc [Concurrency] Fix races/overflows in TaskGroup implementation.
statusCompletePendingReadyWaiting(), offer(), and poll() did a one-off compare_exchange_strong which could fail if the group was concurrently cancelled. Put these into loops so that they are retried when needed.

DiscardingTaskGroup creation passed the group result type as the task result type. waitAll() would then use the group result type when collecting task results. Since the task result type is always Void in this case, this would overflow the result buffer if the group result type was larger. This often works as it writes into the free space of the task allocator, but can crash if it happens to be at the end of a page or the group result type is particularly large.

rdar://151663730
2025-05-28 20:58:33 -04: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
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
a3bf1fc4c2 Merge pull request #75248 from DougGregor/unsafe-inherit-executor-the-rest
Extend _unsafeInheritExecutor_ to remaining @_unsafeInheritExecutor APIs
2024-07-15 18:46:38 -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
Kenta Kubo
7b7110061f [stdlib][docs] Fix the SeeAlso documentation for withDiscardingTaskGroup (#72767)
The SeeAlso documentation for `withDiscardingTaskGroup` is missing trailing backticks.
2024-07-15 13:51:21 +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
3aca6b6ceb Concurrency: Remove superfluous $BuiltinCreateTaskGroupWithFlags 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
Allan Shortlidge
e5744f04d6 Concurrency: Promote BuiltinCreateAsyncDiscardingTaskInGroup feature to baseline. 2024-07-02 22:26:55 -07: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
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
Konrad `ktoso` Malawski
ef80d778dc [Concurrency] Fix the missing builtin guards for DiscardingTaskGroup (#70837) 2024-01-10 22:55:38 -08:00
Yuta Saito
7cccbcc84f [DiscardingTG] Remove reabstraction thunk for () -> Void to () -> T (#70537)
Concurrency runtime expects discarding task operation entrypoint
function not to have result type, but the current SILGen
implementation generates reabstraction thunk to convert `() -> Void`
to `() -> T` for the operation function.

Since the `T` is always `Void` for DiscardingTG, the mismatch of result
type expectation does not cause any problem on most platforms, but the
signature mismatch causes a problem on WebAssembly.

This patch introduces new builtin operations for creating discarding
task, which always takes `() -> Void` as the operation function type.
2024-01-10 07:17:15 +09:00
Alex Martini
e8d86e879e Minor adjustments for Apple style. 2023-09-27 13:31:17 -07:00
Alex Martini
ecdac2e5ae Remove stray whitespace at end of line. 2023-09-27 13:29:54 -07:00
Konrad `ktoso` Malawski
62ffc9f025 Fix cut off sentence and correct Throwing discarding task group docs
We cut off a sentence, this corrects that issue.

resolves rdar://115519046
2023-09-27 12:48:34 +09:00
Konrad `ktoso` Malawski
6bfef94c9e [docs][Concurrency] Include required parameter in group docs
[docs][Concurrency] Fix typo in method signature in code snippets of groups
2023-06-30 12:17:57 +09: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
08c4646a0a Merge pull request #65719 from etcwilde/ewilde/discarding-task-group-availability
Fix DiscardingTaskGroup availability
2023-05-07 18:15:02 -07:00
Evan Wilde
c6f551c683 Fix discarding task-group availability
Discarding task groups aren't available in the 5.8-aligned OS's,
resulting in a loader error at launch if you try to use them.

Bumping the availability attributes to 5.9 on everything in
DiscardingTaskGroup.swift
2023-05-05 15:01:43 -07:00
Konrad `ktoso` Malawski
97d2f4fd36 Fix pointer auth issues for discarding task group operation pointer (#65220) 2023-04-18 12:51:45 +09:00
Konrad `ktoso` Malawski
b666fc672e [Executors] Remote distributed actors get "crash on enqueue" default executor (#64969) 2023-04-10 19:12:03 +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
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
Doug Gregor
9e76023546 Add BuiltinCreateTaskGroupWithFlags feature and use it to guard the builtin 2023-01-11 13:47:28 -08:00
Konrad `ktoso` Malawski
6f38910058 DiscardingTaskGroup now shares some implementation with "Accumulating" TaskGroup 2023-01-09 11:35:04 +09:00
Konrad `ktoso` Malawski
e37b998c56 implement simple rethrowing logic, however body throw always wins 2023-01-05 21:42:20 +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