Skip to content

Commit a07a3f4

Browse files
authored
Rename AsyncLazySequence to AsyncSyncSequence per review feedback (#246)
* Rename AsyncLazySequence to AsyncSyncSequence per review feedback * Rename and number the async proposal
1 parent e7b9b60 commit a07a3f4

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed
+9-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# AsyncLazySequence
1+
# AsyncSyncSequence
22

33
* Proposal: [NNNN](NNNN-lazy.md)
44
* Authors: [Philippe Hausler](https://github.com/phausler)
55
* Status: **Implemented**
66

77
* Implementation:
8-
[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncLazySequence.swift) |
8+
[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncSyncSequence.swift) |
99
[Tests](https://github.com/apple/swift-async-algorithms/blob/main/Tests/AsyncAlgorithmsTests/TestLazy.swift)
1010

1111
## Introduction
1212

13-
`AsyncLazySequence` converts a non-asynchronous sequence into an asynchronous one.
13+
`AsyncSyncSequence` converts a non-asynchronous sequence into an asynchronous one.
1414

1515
This operation is available for all `Sequence` types.
1616

@@ -22,19 +22,19 @@ let characters = "abcde".async
2222
This transformation can be useful to test operations specifically available on `AsyncSequence` but also is useful
2323
to combine with other `AsyncSequence` types to provide well known sources of data.
2424

25-
The `.async` property returns an `AsyncLazySequence` that is generic upon the base `Sequence` it was constructed from.
25+
The `.async` property returns an `AsyncSyncSequence` that is generic upon the base `Sequence` it was constructed from.
2626

2727
```swift
2828
extension Sequence {
29-
public var async: AsyncLazySequence<Self> { get }
29+
public var async: AsyncSyncSequence<Self> { get }
3030
}
3131

32-
public struct AsyncLazySequence<Base: Sequence>: AsyncSequence {
32+
public struct AsyncSyncSequence<Base: Sequence>: AsyncSequence {
3333
...
3434
}
3535

36-
extension AsyncLazySequence: Sendable where Base: Sendable { }
37-
extension AsyncLazySequence.Iterator: Sendable where Base.Iterator: Sendable { }
36+
extension AsyncSyncSequence: Sendable where Base: Sendable { }
37+
extension AsyncSyncSequence.Iterator: Sendable where Base.Iterator: Sendable { }
3838
```
3939

4040
### Naming
@@ -45,4 +45,4 @@ succinct name in inspiration from `.lazy`, and the type is named in reference to
4545

4646
## Effect on API resilience
4747

48-
`AsyncLazySequence` has a trivial implementation and is marked as `@frozen` and `@inlinable`. This removes the ability of this type and functions to be ABI resilient boundaries at the benefit of being highly optimizable.
48+
`AsyncSyncSequence` has a trivial implementation and is marked as `@frozen` and `@inlinable`. This removes the ability of this type and functions to be ABI resilient boundaries at the benefit of being highly optimizable.

Sources/AsyncAlgorithms/AsyncAlgorithms.docc/Guides/Effects.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
| `AsyncInterspersedSequence.Iterator` | rethrows | Not Sendable|
3535
| `AsyncJoinedSequence` | rethrows | Conditional |
3636
| `AsyncJoinedSequence.Iterator` | rethrows | Not Sendable|
37-
| `AsyncLazySequence` | non-throwing | Conditional |
38-
| `AsyncLazySequence.Iterator` | non-throwing | Not Sendable|
37+
| `AsyncSyncSequence` | non-throwing | Conditional |
38+
| `AsyncSyncSequence.Iterator` | non-throwing | Not Sendable|
3939
| `AsyncLimitBuffer` | non-throwing | Sendable |
4040
| `AsyncMerge2Sequence` | rethrows | Sendable |
4141
| `AsyncMerge2Sequence.Iterator` | rethrows | Not Sendable|

Sources/AsyncAlgorithms/AsyncAlgorithms.docc/Guides/Lazy.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# AsyncLazySequence
1+
# AsyncSyncSequence
22

3-
[[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncLazySequence.swift) |
3+
[[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncSyncSequence.swift) |
44
[Tests](https://github.com/apple/swift-async-algorithms/blob/main/Tests/AsyncAlgorithmsTests/TestLazy.swift)]
55

66
Converts a non-asynchronous sequence into an asynchronous one.
@@ -17,19 +17,19 @@ to combine with other `AsyncSequence` types to provide well known sources of dat
1717

1818
## Detailed Design
1919

20-
The `.async` property returns an `AsyncLazySequence` that is generic upon the base `Sequence` it was constructed from.
20+
The `.async` property returns an `AsyncSyncSequence` that is generic upon the base `Sequence` it was constructed from.
2121

2222
```swift
2323
extension Sequence {
24-
public var async: AsyncLazySequence<Self> { get }
24+
public var async: AsyncSyncSequence<Self> { get }
2525
}
2626

27-
public struct AsyncLazySequence<Base: Sequence>: AsyncSequence {
27+
public struct AsyncSyncSequence<Base: Sequence>: AsyncSequence {
2828
...
2929
}
3030

31-
extension AsyncLazySequence: Sendable where Base: Sendable { }
32-
extension AsyncLazySequence.Iterator: Sendable where Base.Iterator: Sendable { }
31+
extension AsyncSyncSequence: Sendable where Base: Sendable { }
32+
extension AsyncSyncSequence.Iterator: Sendable where Base.Iterator: Sendable { }
3333
```
3434

3535
### Naming

Sources/AsyncAlgorithms/AsyncChunksOfCountOrSignalSequence.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public struct AsyncChunksOfCountOrSignalSequence<Base: AsyncSequence, Collected:
7070
public struct Iterator: AsyncIteratorProtocol {
7171
typealias EitherMappedBase = AsyncMapSequence<Base, Either>
7272
typealias EitherMappedSignal = AsyncMapSequence<Signal, Either>
73-
typealias ChainedBase = AsyncChain2Sequence<EitherMappedBase, AsyncLazySequence<[Either]>>
73+
typealias ChainedBase = AsyncChain2Sequence<EitherMappedBase, AsyncSyncSequence<[Either]>>
7474
typealias Merged = AsyncMerge2Sequence<ChainedBase, EitherMappedSignal>
7575

7676
let count: Int?

Sources/AsyncAlgorithms/AsyncLazySequence.swift Sources/AsyncAlgorithms/AsyncSyncSequence.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ extension Sequence {
1414
/// but on which operations, such as `map` and `filter`, are
1515
/// implemented asynchronously.
1616
@inlinable
17-
public var async: AsyncLazySequence<Self> {
18-
AsyncLazySequence(self)
17+
public var async: AsyncSyncSequence<Self> {
18+
AsyncSyncSequence(self)
1919
}
2020
}
2121

@@ -28,7 +28,7 @@ extension Sequence {
2828
/// This functions similarly to `LazySequence` by accessing elements sequentially
2929
/// in the iterator's `next()` method.
3030
@frozen
31-
public struct AsyncLazySequence<Base: Sequence>: AsyncSequence {
31+
public struct AsyncSyncSequence<Base: Sequence>: AsyncSequence {
3232
public typealias Element = Base.Element
3333

3434
@frozen
@@ -66,4 +66,4 @@ public struct AsyncLazySequence<Base: Sequence>: AsyncSequence {
6666
}
6767
}
6868

69-
extension AsyncLazySequence: Sendable where Base: Sendable { }
69+
extension AsyncSyncSequence: Sendable where Base: Sendable { }

Tests/AsyncAlgorithmsTests/TestJoin.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ import XCTest
1313
import AsyncAlgorithms
1414

1515
extension Sequence where Element: Sequence, Element.Element: Equatable & Sendable {
16-
func nestedAsync(throwsOn bad: Element.Element) -> AsyncLazySequence<[AsyncThrowingMapSequence<AsyncLazySequence<Element>,Element.Element>]> {
17-
let array: [AsyncThrowingMapSequence<AsyncLazySequence<Element>,Element.Element>] = self.map { $0.async }.map {
16+
func nestedAsync(throwsOn bad: Element.Element) -> AsyncSyncSequence<[AsyncThrowingMapSequence<AsyncSyncSequence<Element>,Element.Element>]> {
17+
let array: [AsyncThrowingMapSequence<AsyncSyncSequence<Element>,Element.Element>] = self.map { $0.async }.map {
1818
$0.map { try throwOn(bad, $0) }
1919
}
2020
return array.async
2121
}
2222
}
2323

2424
extension Sequence where Element: Sequence, Element.Element: Sendable {
25-
var nestedAsync : AsyncLazySequence<[AsyncLazySequence<Element>]> {
25+
var nestedAsync : AsyncSyncSequence<[AsyncSyncSequence<Element>]> {
2626
return self.map { $0.async }.async
2727
}
2828
}
@@ -55,7 +55,7 @@ final class TestJoinedBySeparator: XCTestCase {
5555
}
5656

5757
func test_join_empty() async {
58-
let sequences = [AsyncLazySequence<[Int]>]().async
58+
let sequences = [AsyncSyncSequence<[Int]>]().async
5959
var iterator = sequences.joined(separator: [-1, -2, -3].async).makeAsyncIterator()
6060
let expected = [Int]()
6161
var actual = [Int]()
@@ -105,7 +105,7 @@ final class TestJoinedBySeparator: XCTestCase {
105105
}
106106

107107
func test_cancellation() async {
108-
let source : AsyncLazySequence<[AsyncLazySequence<Indefinite<String>>]> = [Indefinite(value: "test").async].async
108+
let source : AsyncSyncSequence<[AsyncSyncSequence<Indefinite<String>>]> = [Indefinite(value: "test").async].async
109109
let sequence = source.joined(separator: ["past indefinite"].async)
110110
let finished = expectation(description: "finished")
111111
let iterated = expectation(description: "iterated")
@@ -158,7 +158,7 @@ final class TestJoined: XCTestCase {
158158
}
159159

160160
func test_join_empty() async {
161-
let sequences = [AsyncLazySequence<[Int]>]().async
161+
let sequences = [AsyncSyncSequence<[Int]>]().async
162162
var iterator = sequences.joined().makeAsyncIterator()
163163
let expected = [Int]()
164164
var actual = [Int]()
@@ -189,7 +189,7 @@ final class TestJoined: XCTestCase {
189189
}
190190

191191
func test_cancellation() async {
192-
let source : AsyncLazySequence<[AsyncLazySequence<Indefinite<String>>]> = [Indefinite(value: "test").async].async
192+
let source : AsyncSyncSequence<[AsyncSyncSequence<Indefinite<String>>]> = [Indefinite(value: "test").async].async
193193
let sequence = source.joined()
194194
let finished = expectation(description: "finished")
195195
let iterated = expectation(description: "iterated")

0 commit comments

Comments
 (0)