Skip to content

Commit af684d5

Browse files
author
Thibault Wittemberg
committed
Merge branch 'improve/sync-send'
2 parents 2f9732b + ef04ef2 commit af684d5

4 files changed

Lines changed: 9 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
**v0.3.0 - Beryllium:**
22

3-
- new Share operator
4-
- new Timer AsyncSequence
3+
- Operators: new Share operator
4+
- AsyncSequences: new Timer AsyncSequence
5+
- AsyncStreams: `send()` functions are now synchronous
56

67
**v0.2.1 - Lithium:**
78

Sources/AsyncStreams/AsyncStreams+CurrentValue.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public final class AsyncCurrentValueStream<Element>: Stream, @unchecked Sendable
8585
/// Sends a value to all underlying async sequences
8686
/// - Parameter element: the value to send
8787
public func send(_ element: Element) {
88-
self.serialQueue.async { [weak self] in
88+
self.serialQueue.sync { [weak self] in
8989
self?.storage.update(element)
9090
self?.continuations.send(element)
9191
}
@@ -94,7 +94,7 @@ public final class AsyncCurrentValueStream<Element>: Stream, @unchecked Sendable
9494
/// Finishes the async sequences with either a normal ending or an error.
9595
/// - Parameter termination: The termination to finish the async sequence.
9696
public func send(termination: Termination) {
97-
self.serialQueue.async { [weak self] in
97+
self.serialQueue.sync { [weak self] in
9898
self?.continuations.send(termination)
9999
}
100100
}

Sources/AsyncStreams/AsyncStreams+Passthrough.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ public final class AsyncPassthroughStream<Element>: Stream, @unchecked Sendable
5151
/// Sends a value to all underlying async sequences
5252
/// - Parameter element: the value to send
5353
public func send(_ element: Element) {
54-
self.serialQueue.async { [weak self] in
54+
self.serialQueue.sync { [weak self] in
5555
self?.continuations.send(element)
5656
}
5757
}
5858

5959
/// Finishes the async sequences with either a normal ending or an error.
6060
/// - Parameter termination: The termination to finish the async sequence.
6161
public func send(termination: Termination) {
62-
self.serialQueue.async { [weak self] in
62+
self.serialQueue.sync { [weak self] in
6363
self?.continuations.send(termination)
6464
}
6565
}

Sources/AsyncStreams/AsyncStreams+Replay.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public final class AsyncReplayStream<Element>: Stream, @unchecked Sendable {
7676
/// Sends a value to all underlying async sequences
7777
/// - Parameter element: the value to send
7878
public func send(_ element: Element) {
79-
self.serialQueue.async { [weak self] in
79+
self.serialQueue.sync { [weak self] in
8080
self?.storage.push(element)
8181
self?.continuations.send(element)
8282
}
@@ -85,7 +85,7 @@ public final class AsyncReplayStream<Element>: Stream, @unchecked Sendable {
8585
/// Finishes the async sequences with either a normal ending or an error.
8686
/// - Parameter completion: The termination to finish the async sequence.
8787
public func send(termination: Termination) {
88-
self.serialQueue.async { [weak self] in
88+
self.serialQueue.sync { [weak self] in
8989
self?.continuations.send(termination)
9090
self?.storage.clear()
9191
}

0 commit comments

Comments
 (0)