Skip to content

Commit 110e2a0

Browse files
author
Thibault Wittemberg
committed
streams: set send() synchronous
1 parent 2f9732b commit 110e2a0

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

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)