* First draft docs for iterator, sequence type.
Also drop(while:), to get a feel for the AsyncSequence->AsyncSequence cases.
* Source docs for contains and reduce.
* Docs for methods in AsyncSequence.
This covers all the methods that return a single value. Still working on the extension methods that return new sequences.
* Early source docs for dropFirst(_:) and its type
* Correct doc format for dropFirst(_:).
* Prefix, plus some fixes.
* Docs for prefix(while:).
* Apply Philippe's snippet fixes.
* First draft docs on the map sequences.
Plus miscellaneous fixes throughout.
* Show result of flatMap example.
* More explicit cancellation guidance.
* Convert snippets to trailing closures.
* Correct misplaced doc comments.
* Apply suggestions from code review
Co-authored-by: Philippe Hausler <phausler@apple.com>
* Apply editorial feedback.
* Apply additional editorial feedback.
* Apply suggestions from code review
Co-authored-by: bjlanier <blanier@apple.com>
* Apply further editorial feedback.
Co-authored-by: Chris Adamson <cadamson@apple.com>
Co-authored-by: Philippe Hausler <phausler@apple.com>
Co-authored-by: bjlanier <blanier@apple.com>
HAVE_PTHREAD_H is supplied in this config file.
The `__has_include` pattern is discouraged, but there is no other way of
conditioning on `pthread_np.h`, which is required for `pthread_main_np`
on OpenBSD. Therefore, use it, but call it out in a comment.
* 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>
This commit changes JobFlags storage to be 32bits, but leaves the runtime
API expressed in terms of size_t. This allows us to pack an Id in the
32bits we freed up.
The offset of this Id in the AsyncTask is an ABI constant. This way
introspection tools can extract the currently running task identifier
without any need for special APIs.
* [Concurrency] Reduce overhead of Task.yield and Task.sleep
Instead of creating a new task, we create a simple job that wraps a Builtin.RawUnsafeContinuation and resumes the continuation when it is executed. The job instance is allocated on the task local allocator, meaning we don't malloc anything.
* Update stdlib/public/Concurrency/Task.swift
Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>
Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>
Rename duplicated `swift::fatalError` in `swiftRuntime` and `swift_Concurrency`.
Both `swiftRuntime` and `swift_Concurrency` had `swift::fatalError` implementation, but it causes symbol conflict with the `-static-stdlib` flag.
This patch removes one of the implementations in `swift_Concurrency` to avoid conflicts. Also added a test case to ensure that linking the Concurrency module with `-static-stdlib` works.
This issue was found by SwiftWasm test cases.
The use of an availability macro will make it easier to update those
versions to the marketing versions when they are announced. Plus
internal branches can redefine only the macro for customized
availability.
- Introduce an UnownedSerialExecutor type into the concurrency library.
- Create a SerialExecutor protocol which allows an executor type to
change how it executes jobs.
- Add an unownedExecutor requirement to the Actor protocol.
- Change the ABI for ExecutorRef so that it stores a SerialExecutor
witness table pointer in the implementation field. This effectively
makes ExecutorRef an `unowned(unsafe) SerialExecutor`, except that
default actors are represented without a witness table pointer (just
a bit-pattern).
- Synthesize the unownedExecutor method for default actors (i.e. actors
that don't provide an unownedExecutor property).
- Make synthesized unownedExecutor properties `final`, and give them
a semantics attribute specifying that they're for default actors.
- Split `Builtin.buildSerialExecutorRef` into a few more precise
builtins. We're not using the main-actor one yet, though.
Pitch thread:
https://forums.swift.org/t/support-custom-executors-in-swift-concurrency/44425
Per updates to the Structured Concurrency protocol, make the `async`
operation (1) overloaded on throwing-ness and (2) return an appropriate
`Task.Handle`.
When `Task.currentPriority` is evaluated outside of an actual task,
query the system to determine the priority at which the code is
currently executing. This is the behavior that `async` specifies.
Extend that to `currentPriority` rather than guessing `.default`.
Both swiftRuntime and swift_Concurrency had swift::fatalError
implementation, but it causes symbol conflict when -static-stdlib.
This patch renames one of the impl in swift_Concurrency to avoid
conflict.
Based on feedback, perform the adjustment from userInteractive to
userInitiated all the time, and rely on `qos_class_self` whenever we
don't have a task.
Given that `async` is the dominant way to initiate asynchronous work from
a synchronous function, speculatively rename `detach` to `asyncDetached`
to both fit into the naming scheme and clearly bias toward `async.
Also, do this for the initial slab for the task's allocator itself.
This avoids memory allocations for async-lets.
In case the async-task's memory demand does not exceed the initial slab size, it is now completely malloc-free.
The refcount bits of an async-let task are initialized to "immortal" so that ARC operations don't have an effect on the task.