The channel and debounce sources moved into Channels/ and Debounce/,
AsyncChunksOfCountAndSignalSequence.swift is now
AsyncChunksOfCountOrSignalSequence.swift, and the Collections guide
lives in the DocC catalog, so these links return 404.
Rename 0016-mutli-producer-single-consumer-channel.md to the
correctly spelled 0016-multi-...; the document's own proposal link
already uses the correct spelling and currently 404s. Fill in the
NNNN template placeholder in 0017-map-error.md's proposal link.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* rename the map error proposal to have a specific number
* rename the flatMapLatest proposal to have a specific numbering
* Update availability markers for flatmapLatest
* Cleanup formatting pass for FlatMapLatest
* Remove stray extra single quote
* Add a fallback for older versions of swift for the next method on flatMapLatest
* feat: Add initial naive implementation of flatMapLatest
This introduces a simplified version of the flatMapLatest operator for AsyncSequence, along with a basic unit test. Note that this implementation uses unstructured concurrency and may have race conditions regarding task cancellation.
* refactor: Implement robust flatMapLatest with generation tracking
- Replaces naive implementation with a thread-safe approach using ManagedCriticalState.
- Introduces generation tracking to prevent race conditions where cancelled inner sequences could yield stale values.
- Adds test_interleaving_race_condition to verify correctness under concurrent load.
- Ensures Swift 6 Sendable compliance.
* refactor: Implement high-performance State Machine for flatMapLatest
- Replaces AsyncThrowingStream implementation with a custom AsyncSequence, Storage, and StateMachine.
- Implements explicit state management using Lock for thread safety.
- Handles concurrency between outer and inner sequences robustly.
- Ensures correct cancellation propagation and error handling.
- Verified with test_interleaving_race_condition.
* refactor: Split flatMapLatest into separate files
- Moves AsyncFlatMapLatestSequence.swift to Sources/AsyncAlgorithms/FlatMapLatest/
- Extracts FlatMapLatestStateMachine and FlatMapLatestStorage into their own files.
- Aligns project structure with other complex operators like CombineLatest and Debounce.
* test: Add comprehensive tests for flatMapLatest
- Added test_outer_throwing to verify outer sequence error propagation
- Added test_inner_throwing to verify inner sequence error propagation
- Added test_cancellation to verify proper cancellation handling
- Added test_empty_outer to verify empty outer sequence handling
- Added test_empty_inner to verify empty inner sequence handling
- Fixed test_simple_sequence to be more robust against timing issues
* fix: Make test_outer_throwing stable
- Changed from synchronous map with throwIf to AsyncThrowingStream
- Added delay to ensure proper error propagation timing
- Fixes intermittent test failures
* refactor: Clean up verbose comments in FlatMapLatestStateMachine
- Removed LLM-style thinking comments
- Kept only essential, professional explanations
- No functional changes, all tests pass
* docs: Add comprehensive guide for flatMapLatest
- Added FlatMapLatest.md documentation guide
- Authored by Peter Friese
- Includes introduction, code samples, and use cases
- Covers search-as-you-type, location-based data, and dynamic config examples
- Compares with similar operators in ReactiveX and Combine
* docs: Add evolution proposal for flatMapLatest
- Created SAA-00nn proposal for flatMapLatest operator
- Includes motivation, detailed design, and examples
- Covers implementation strategy with state machine
- Compares with ReactiveX switchMap and Combine switchToLatest
* mapError - transforming failures (#366)
* Implement AsyncMapErrorSequence
* Update the proposal, implementation and tests with formatting, additional details and modifications for being able to push it to a review
* Foratting and preambles
* Update Copyright date for error sequence
Co-authored-by: Clive <clive819@users.noreply.github.com>
* Update copyright year for mapError tests
Co-authored-by: Clive <clive819@users.noreply.github.com>
* Update availablity and modify the mapError algorithm to be opaque
* Correct pre 6.0 build avail parameters
* Make the formatting of the algorithm accesor a bit more consistent
* Update the 5.8 package builder to define 1.2
* re-run formatter
---------
Co-authored-by: Clive <clive819@gmail.com>
Co-authored-by: Clive <clive819@users.noreply.github.com>
* Update the flatMapLatest proposal and implementation to a pitchable state
* Fix race condition in flatMapLatest and add regression test
* chore: Remove test_output.log and add it to .gitignore
---------
Co-authored-by: Philippe Hausler <phausler@apple.com>
Co-authored-by: Clive <clive819@gmail.com>
Co-authored-by: Clive <clive819@users.noreply.github.com>
* Implement AsyncMapErrorSequence
* Update the proposal, implementation and tests with formatting, additional details and modifications for being able to push it to a review
* Foratting and preambles
* Update Copyright date for error sequence
Co-authored-by: Clive <clive819@users.noreply.github.com>
* Update copyright year for mapError tests
Co-authored-by: Clive <clive819@users.noreply.github.com>
* Update availablity and modify the mapError algorithm to be opaque
* Correct pre 6.0 build avail parameters
* Make the formatting of the algorithm accesor a bit more consistent
* Update the 5.8 package builder to define 1.2
* re-run formatter
---------
Co-authored-by: Clive <clive819@gmail.com>
Co-authored-by: Clive <clive819@users.noreply.github.com>
* Add `AsyncBackpressuredStream` proposal and implementation
# Motivation
The pitch to add external backpressure support to the standard libraries `AsyncStream` got returned for revision since there are larger open questions around `AsyncSequence`. However, having external backpressure in a source asynchronous sequence is becoming more and more important.
# Modification
This PR adds a modified proposal and implementation that brings the Swift Evolution proposal over to Swift Async Algorithms.
* Update proposal and implementation
* Update proposal
* Add example project
* Formatting
* Fix Swift 6.0 build
* Future direction for ~Copyable elements
* Apply formatting
* Fix CI
* Move to 6.1 and update proposal
* Guard tests
* Minor edits to the proposal
* Fix revision order
* FIxup setOnTerminationCallback
* Address review feedback
* Rename to `MultiProducerSingleConsumerAsyncChannel`
* Allow one termination callback per source.
* Fix all sendable warnings
* Remove unbounded strategy, rename copy -> makeAdditionalSource, rename asyncSequence() -> elements(), and move enqueue and cancel to the `CallbackHandle` previously called `CallbackToken`
* Remove Example and fix docs and fix format
* fixes grammar and some word order issues
* Remove unnecessary consume
---------
Co-authored-by: Joe Heck <j_heck@apple.com>
This is an implementation of share; an algorithm for allowing AsyncSequence types to be iterated by multiple consumers. In addition this cleans up the project to be a starting point for the 1.1 release - it fixes the continuous integration support and configurations but has the cost of only supporting 3 active releases (6.0, 6.1, and 6.2). Previous releases are only going to have legacy support via older released versions.
* Fix the remaining todo on hard cancellation vs soft cancellation
* Update Sources/AsyncAlgorithms/AsyncShareSequence.swift
Co-authored-by: Jamie <2119834+jamieQ@users.noreply.github.com>
* Update the implementation of share to handle sendability requirements, address some edge cases and update to the latest version of the discussion around buffering behaviors as well as adding some documentation and commentary
* Add some first drafts at unit tests for verifying share behaviors
* Cleanup some of the documentation and address feedback for implementation details
* Fix merge damage by restoring the changes from @jamieQ
* Fix up some availability issues w.r.t. sendable metatypes
* Add a preamble to SendableMetatypes.swift
* Add a fallback for next (for pre 6.2 swift's)
* Slight adjustments for older compiler builds and expose the sendable metatypes since those are part of documentation
* Update formatting and gate availability for older compilers
* Speculative fix for pre 6.1 compiler crashes by removing the sending keyword
* Revert "Speculative fix for pre 6.1 compiler crashes by removing the sending keyword"
This reverts commit 875fa81bc6.
* Speculative fix for pre 6.1 compiler crashes by removing the sending keyword, and correct sendable metatype shim availability
* Remove block comment for formatting check
* Take a more conservative approach and roll back to only supporting share on 6.2
* Only test share on 6.2 or newer
* roll back to older sendable metatype constraints
* yet another stab at 5.10 visionOS guards
* Formatting pass
* Disable 5.10 builds and leave those to older releases
* Ignore swift-version files to avoid local swiftly toolchain selection from being required by others
* Renumber the proposals and copy share into a guide
* Add a link from the primary doc interface to share
---------
Co-authored-by: Jamie <2119834+jamieQ@users.noreply.github.com>
* Integrate review feedback
This integrates all of the feedback from the review thread. Here is a quick summary:
- Change the trailing separator behaviour. We are no longer returning a separator before we are forwarding the error
- Add a synchronous and asynchronous closure based `interspersed` method.
- Support interspersing every n elements
* Add AsyncThrowingInterspersedSequence
* Update examples
* Clean up old evolution proposals
# Motivation
Our old proposals had a couple of stale links and were not all aligned. This cleans them up.
* Add Interspersed proposal
# Motivation
Add a new evolution proposal for the interspersed algorithm.
* Set up a directory for proposals for evolving swift-async-algorithms
* Remove some langauge in the proposal template that is more focused upon Swift as a language rather than library evolution
* Update Evoluition/0000-swift-async-algorithms-template.md
Co-authored-by: Tony Parker <anthony.parker@apple.com>
* Correct typo of directory name for evolution
* Update bug listing to the github issues link
* Remove ABI consideration section and just leave API resilience
Co-authored-by: Tony Parker <anthony.parker@apple.com>