Skip to content

Commit 3523cd3

Browse files
committed
Address review feedback
1 parent 02b6c86 commit 3523cd3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Evolution/0016-mutli-producer-single-consumer-channel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ production APIs and has an effective buffer of one per producer. This means that
760760
any producer will be suspended until its value has been consumed. `AsyncChannel`
761761
can handle multiple consumers and resumes them in FIFO order.
762762

763-
### swift-nio: NIOAsyncSequenceProducer
763+
### swift-nio: NIOAsyncSequenceProducer
764764

765765
The NIO team have created their own root asynchronous sequence with the goal to
766766
provide a high performance sequence that can be used to bridge a NIO `Channel`

Sources/AsyncAlgorithms/MultiProducerSingleConsumerChannel/MultiProducerSingleConsumerChannel.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public struct MultiProducerSingleConsumerChannel<Element, Failure: Error>: ~Copy
161161
of elementType: Element.Type = Element.self,
162162
throwing failureType: Failure.Type = Never.self,
163163
backpressureStrategy: Source.BackpressureStrategy
164-
) -> ChannelAndStream {
164+
) -> sending ChannelAndStream {
165165
let storage = _Storage(
166166
backpressureStrategy: backpressureStrategy.internalBackpressureStrategy
167167
)
@@ -209,7 +209,7 @@ extension MultiProducerSingleConsumerChannel {
209209
/// A struct to send values to the channel.
210210
///
211211
/// Use this source to provide elements to the channel by calling one of the `send` methods.
212-
public struct Source: ~Copyable, Sendable {
212+
public struct Source: ~Copyable {
213213
/// A struct representing the backpressure of the channel.
214214
public struct BackpressureStrategy: Sendable {
215215
var internalBackpressureStrategy: _InternalBackpressureStrategy
@@ -234,8 +234,8 @@ extension MultiProducerSingleConsumerChannel {
234234
/// - high: When the number of buffered elements rises above the high watermark, producers will be suspended.
235235
/// - waterLevelForElement: A closure used to compute the contribution of each buffered element to the current water level.
236236
///
237-
/// - Note, `waterLevelForElement` will be called on each element when it is written into the source and when
238-
/// it is consumed from the channel, so it is recommended to provide a function that runs in constant time.
237+
/// - Important: `waterLevelForElement` will be called during a lock on each element when it is written into the source and when
238+
/// it is consumed from the channel, so it must be side-effect free and at best constant in time.
239239
public static func watermark(
240240
low: Int,
241241
high: Int,
@@ -446,7 +446,7 @@ extension MultiProducerSingleConsumerChannel {
446446
public mutating func send<S>(
447447
contentsOf sequence: consuming sending S
448448
) async throws where Element == S.Element, S: Sequence, Element: Copyable {
449-
let syncSend: (sending S, inout sending Self) throws -> SendResult = { try $1.send(contentsOf: $0) }
449+
let syncSend: (sending S, inout Self) throws -> SendResult = { try $1.send(contentsOf: $0) }
450450
let sendResult = try syncSend(sequence, &self)
451451

452452
switch consume sendResult {
@@ -481,7 +481,7 @@ extension MultiProducerSingleConsumerChannel {
481481
/// - element: The element to send to the channel.
482482
@inlinable
483483
public mutating func send(_ element: consuming sending Element) async throws {
484-
let syncSend: (consuming sending Element, inout sending Self) throws -> SendResult = { try $1.send($0) }
484+
let syncSend: (consuming sending Element, inout Self) throws -> SendResult = { try $1.send($0) }
485485
let sendResult = try syncSend(element, &self)
486486

487487
switch consume sendResult {

0 commit comments

Comments
 (0)