Skip to content

Commit

Permalink
update async channels (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc authored Oct 22, 2024
1 parent 6a84380 commit 1bb83f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Networking/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-certificates.git", from: "1.5.0"),
.package(url: "https://github.com/apple/swift-testing.git", branch: "0.10.0"),
.package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.0"),
.package(url: "https://github.com/gh123man/Async-Channels.git", from: "1.0.2"),
],
targets: [
.target(
Expand Down
10 changes: 5 additions & 5 deletions Networking/Sources/Networking/Stream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ final class Stream<Handler: StreamHandler>: Sendable, StreamProtocol {
if data.isEmpty {
return
}
// TODO: backpressure handling
// https://github.com/gh123man/Async-Channels/issues/11
Task {
await channel.send(data)

if !channel.syncSend(data) {
logger.warning("stream \(id) is full")
// TODO: backpressure handling
}
}

// initiate stream close
public func close(abort: Bool = false) {
if status != .open {
logger.warning("Trying to close stream \(stream.id) in status \(status)")
logger.warning("Trying to close stream \(id) in status \(status)")
return
}
status = abort ? .aborted : .closed
Expand Down

0 comments on commit 1bb83f2

Please sign in to comment.