Skip to content

Commit 1bb83f2

Browse files
authored
update async channels (#188)
1 parent 6a84380 commit 1bb83f2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Networking/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let package = Package(
2020
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"),
2121
.package(url: "https://github.com/apple/swift-certificates.git", from: "1.5.0"),
2222
.package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"),
23-
.package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.0"),
23+
.package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"),
2424
],
2525
targets: [
2626
.target(

Networking/Sources/Networking/Stream.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@ final class Stream<Handler: StreamHandler>: Sendable, StreamProtocol {
7171
if data.isEmpty {
7272
return
7373
}
74-
// TODO: backpressure handling
75-
// https://github.com/gh123man/Async-Channels/issues/11
76-
Task {
77-
await channel.send(data)
74+
75+
if !channel.syncSend(data) {
76+
logger.warning("stream \(id) is full")
77+
// TODO: backpressure handling
7878
}
7979
}
8080

8181
// initiate stream close
8282
public func close(abort: Bool = false) {
8383
if status != .open {
84-
logger.warning("Trying to close stream \(stream.id) in status \(status)")
84+
logger.warning("Trying to close stream \(id) in status \(status)")
8585
return
8686
}
8787
status = abort ? .aborted : .closed

0 commit comments

Comments
 (0)