Commit Graph

18 Commits

Author SHA1 Message Date
Mykola Pokhylets
1b2e03189b Added Hashable conformance to Async(Throwing)Stream.Continuation 2025-04-12 14:12:54 +02:00
Holly Borla
d2d317a3d7 [Concurrency] Fix preconcurrency downgrade behavior for Sendable closures.
Sendable violations inside `@preconcurrency @Sendable` closures should be
suppressed in minimal checking, and diagnosed as warnings under complete
checking, including the Swift 6 language mode.
2024-11-07 16:02:37 -08:00
Jamie
3bea96a310 [stdlib]: Propagate AsyncStream termination to all consumers
As of the changes in https://github.com/swiftlang/swift/pull/41713 to
enable Sendability for AsyncStream, it has been possible to create
multiple stream consumers operating concurrently. This change fixes
behavior in the case that the underlying stream is terminated while
multiple pending continuations are outstanding. Previously such
consumers would have been leaked (never resumed). Now, they are notified
of the stream's termination and resumed appropriately.

Resolves #66541 & #71412
2024-08-20 07:26:18 -05:00
Holly Borla
377b5274ff [Concurrency] Async{Throwing}Stream.init(unfolding:) should accept a
`@Sendable` closure.
2024-03-12 22:55:34 -07:00
Konrad `ktoso` Malawski
6883592e74 Disable async-stream test in freestanding mode 2023-03-10 18:50:54 +09:00
Franz Busch
791b2a0298 Implement convenience factory methods for Async[Throwing]Stream (#62968)
* Implement convenience factory methods for Async[Throwing]Stream

This is the implementation for https://github.com/apple/swift-evolution/pull/1824

* Apply suggestions from code review

Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>

---------

Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>
2023-03-04 17:43:56 -08:00
Yuta Saito
f6b91c1c37 Concurrency: Enable runtime tests for non-libdispatch global executor 2022-02-20 23:58:14 +00:00
Saleem Abdulrasool
7f67dcb1f9 test: enable async/Distributed tests on Windows
These were previously disabled due to the UB that caused the tests to
fail.  Now that this has been fixed, restore these tests to running
state in line with the other targets.
2021-11-20 08:24:25 -08:00
Doug Gregor
353daabf8d Replace UnsafeSendable with @unchecked Sendable in the standard library. 2021-11-12 07:56:10 -08:00
Karoy Lorentey
e2cfab4f28 [stdlib][test] Adopt availability macros in tests 2021-10-31 15:00:58 -07:00
Doug Gregor
3ee09a2298 Switch concurrency runtime tests to "REQUIRES: concurrency_runtime"
Rather than blanket-disabling concurrency tests when we aren't using a
just-built concurrency library, enable them whenever we have a
suitable concurrency runtime, either just-built, in the OS, or via the
back-deployment libraries.
2021-09-13 12:34:20 -07:00
Doug Gregor
eeeea49764 Remove -enable-experimental-concurrency almost everywhere. 2021-07-26 21:24:43 -07:00
Doug Gregor
1e2012d816 Disable availability checking in tests that use concurrency 2021-07-20 12:46:26 -07:00
Philippe Hausler
b813e5a1fe [Concurrency] Remove some tests that are inherently race conditions for AsyncStream 2021-06-24 12:00:38 -07:00
Andrew Trick
2e77557f8e Disable Concurrency/Runtime/async_stream.swift
This test has a race condition which can cause PR testing to fail,
blocking other work.

rdar://78033828 (Swift CI: timeout)
2021-05-19 09:05:50 -07:00
Andrew Trick
5a1689f23f Disable Concurrency/Runtime/async_stream.swift for armv7s
dyld: Symbol not found: _concurrencyEnableCooperativeQueues

rdar://78109470
2021-05-17 13:09:09 -07:00
Arnold Schwaighofer
f82edf72c7 Mark test async_stream as executable_test
It fails on non_executable bots.

rdar://77963528
2021-05-13 06:26:10 -07:00
Philippe Hausler
4886bd56e4 [Concurrency] AsyncStream and AsyncThrowingStream
* Rework YieldingContinuation to service values in a buffered fashion

* Fix word size calculation for locks

* Handle terminal states and finished/failed storage

* Wrap yielding continuation into a more featureful type for better ergonomics

* Hope springs eternal, maybe windows works with this?

* Prevent value overflows at .max limits

* Add a cancellation handler

* Fix series tests missing continuation parameters

* Fix series tests for mutable itertaors

* Rename to a more general name for Series's inner continuation type

* Whitespace fixes and add more commentary about public functions on Series

* Restore YieldingContinuation for now with deprecations to favor Series

* Ensure onCancel is invoked in deinit phases, and eliminate a potential for double cancellation

* Make sure ThrowingSeries has the same nonmutating setter for onCancel as Series

* Add a swath of more unit tests that exersize cancellation behavior as well as throwing behaviors

* Remove work-around for async testing

* Fixup do/catch range to properly handle ThrowingSeries test

* Address naming consistency of resume result function

* Adopt the async main test setup

* More migration of tests to new async mechanisms

* Handle the double finish/throw case

* Ensure the dependency on Dispatch is built for the series tests (due to semaphore usage)

* Add import-libdispatch to run command for Series tests

* Use non-combine based timeout intervals (portable to linux) for dispatch semaphore

* Rename Series -> AsyncStream and resume functions to just yield, and correct a missing default Element.self value

* Fix missing naming change issue for yielding an error on AsyncThrowingStream

* Remove argument label of buffering from tests

* Extract buffer and throwing variants into their own file

* Slightly refactor for only needing to store the producer instead of producer and cancel

* Rename onCancel to onTermination

* Convert handler access into a function pair

* Add finished states to the termination handler event pipeline and a disambiguation enum to identify finish versus cancel

* Ensure all termination happens before event propigation (and outside of the locks) and warn against requirements for locking on terminate and enqueue

* Modified to use Deque to back the storage and move the storage to inner types; overall perf went from 200kE/sec to over 1ME/sec

* Update stdlib/public/Concurrency/AsyncStream.swift

Co-authored-by: Doug Gregor <dgregor@apple.com>

* Update stdlib/public/Concurrency/AsyncThrowingStream.swift

Co-authored-by: Doug Gregor <dgregor@apple.com>

* Update stdlib/public/Concurrency/AsyncStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Update stdlib/public/Concurrency/AsyncThrowingStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Update stdlib/public/Concurrency/AsyncThrowingStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Update stdlib/public/Concurrency/AsyncThrowingStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Update stdlib/public/Concurrency/AsyncStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Update stdlib/public/Concurrency/AsyncThrowingStream.swift

Co-authored-by: Joseph Heck <heckj@mac.com>

* Remove local cruft for overlay disabling

* Remove local cruft for Dispatch overlay work

* Remove potential ABI impact for adding Deque

Co-authored-by: Doug Gregor <dgregor@apple.com>
Co-authored-by: Joseph Heck <heckj@mac.com>
2021-05-11 21:41:33 -07:00