Skip to content

Commit 5c1bfb7

Browse files
committed
merge: optimize task creation and remove sendable constraint
1 parent 68c8dc2 commit 5c1bfb7

File tree

4 files changed

+259
-408
lines changed

4 files changed

+259
-408
lines changed

Sources/AsyncAlgorithms/AsyncChannel.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public final class AsyncChannel<Element: Sendable>: AsyncSequence, Sendable {
2828
init(_ channel: AsyncChannel<Element>) {
2929
self.channel = channel
3030
}
31-
31+
32+
33+
3234
/// Await the next sent element or finish.
3335
public mutating func next() async -> Element? {
3436
guard active else {
@@ -116,7 +118,7 @@ public final class AsyncChannel<Element: Sendable>: AsyncSequence, Sendable {
116118

117119
/// Create a new `AsyncChannel` given an element type.
118120
public init(element elementType: Element.Type = Element.self) { }
119-
121+
120122
func establish() -> Int {
121123
state.withCriticalRegion { state in
122124
defer { state.generation &+= 1 }

Sources/AsyncAlgorithms/AsyncChunksOfCountOrSignalSequence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public struct AsyncChunksOfCountOrSignalSequence<Base: AsyncSequence, Collected:
6868
self.count = count
6969
self.state = Merge2StateMachine(base, terminatesOnNil: true, signal)
7070
}
71-
71+
7272
public mutating func next() async rethrows -> Collected? {
7373
var result : Collected?
7474
while let next = try await state.next() {

0 commit comments

Comments
 (0)