mirror of
https://github.com/apple/swift-async-algorithms
synced 2026-11-24 04:17:52 +00:00
Light edit of recent doc comments. (#98)
Co-authored-by: Chris Adamson <cadamson@apple.com>
This commit is contained in:
1 parent
718d647945
commit
33494899af
6 files changed
+15
-15
No files matched your search
@@ -10,14 +10,14 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
extension AsyncSequence where Element: AsyncSequence {
|
||||
/// Concatenate an `AsyncSequence` of `AsyncSequence` elements with a seperator.
|
||||
/// Concatenate an `AsyncSequence` of `AsyncSequence` elements with a separator.
|
||||
@inlinable
|
||||
public func joined<Separator: AsyncSequence>(separator: Separator) -> AsyncJoinedBySeparatorSequence<Self, Separator> {
|
||||
return AsyncJoinedBySeparatorSequence(self, separator: separator)
|
||||
}
|
||||
}
|
||||
|
||||
/// An `AsyncSequence` that concatenates`AsyncSequence` elements with a seperator.
|
||||
/// An `AsyncSequence` that concatenates `AsyncSequence` elements with a separator.
|
||||
public struct AsyncJoinedBySeparatorSequence<Base: AsyncSequence, Separator: AsyncSequence>: AsyncSequence where Base.Element: AsyncSequence, Separator.Element == Base.Element.Element {
|
||||
public typealias Element = Base.Element.Element
|
||||
public typealias AsyncIterator = Iterator
|
||||
|
||||
@@ -24,7 +24,7 @@ extension AsyncSequence {
|
||||
return AsyncRemoveDuplicatesSequence(self, predicate: predicate)
|
||||
}
|
||||
|
||||
/// Creates an asynchronous sequence that omits repeated elements by testing them with a predicate.
|
||||
/// Creates an asynchronous sequence that omits repeated elements by testing them with an error-throwing predicate.
|
||||
public func removeDuplicates(by predicate: @escaping @Sendable (Element, Element) async throws -> Bool) -> AsyncThrowingRemoveDuplicatesSequence<Self> {
|
||||
return AsyncThrowingRemoveDuplicatesSequence(self, predicate: predicate)
|
||||
}
|
||||
@@ -89,7 +89,7 @@ extension AsyncRemoveDuplicatesSequence: Sendable where Base: Sendable, Base.Ele
|
||||
extension AsyncRemoveDuplicatesSequence.Iterator: Sendable where Base: Sendable, Base.Element: Sendable, Base.AsyncIterator: Sendable { }
|
||||
|
||||
|
||||
/// An asynchronous sequence that omits repeated elements by testing them with a predicate.
|
||||
/// An asynchronous sequence that omits repeated elements by testing them with an error-throwing predicate.
|
||||
public struct AsyncThrowingRemoveDuplicatesSequence<Base: AsyncSequence>: AsyncSequence {
|
||||
public typealias Element = Base.Element
|
||||
|
||||
|
||||
@@ -10,19 +10,19 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
extension AsyncSequence {
|
||||
/// Create a rate limited `AsyncSequence` by emitting values at most every specified interval.
|
||||
/// Create a rate-limited `AsyncSequence` by emitting values at most every specified interval.
|
||||
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
||||
public func throttle<C: Clock, Reduced>(for interval: C.Instant.Duration, clock: C, reducing: @Sendable @escaping (Reduced?, Element) async -> Reduced) -> AsyncThrottleSequence<Self, C, Reduced> {
|
||||
AsyncThrottleSequence(self, interval: interval, clock: clock, reducing: reducing)
|
||||
}
|
||||
|
||||
/// Create a rate limited `AsyncSequence` by emitting values at most every specified interval.
|
||||
/// Create a rate-limited `AsyncSequence` by emitting values at most every specified interval.
|
||||
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
||||
public func throttle<Reduced>(for interval: Duration, reducing: @Sendable @escaping (Reduced?, Element) async -> Reduced) -> AsyncThrottleSequence<Self, ContinuousClock, Reduced> {
|
||||
throttle(for: interval, clock: .continuous, reducing: reducing)
|
||||
}
|
||||
|
||||
/// Create a rate limited `AsyncSequence` by emitting values at most every specified interval.
|
||||
/// Create a rate-limited `AsyncSequence` by emitting values at most every specified interval.
|
||||
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
||||
public func throttle<C: Clock>(for interval: C.Instant.Duration, clock: C, latest: Bool = true) -> AsyncThrottleSequence<Self, C, Element> {
|
||||
throttle(for: interval, clock: clock) { previous, element in
|
||||
@@ -34,14 +34,14 @@ extension AsyncSequence {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a rate limited `AsyncSequence` by emitting values at most every specified interval.
|
||||
/// Create a rate-limited `AsyncSequence` by emitting values at most every specified interval.
|
||||
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
||||
public func throttle(for interval: Duration, latest: Bool = true) -> AsyncThrottleSequence<Self, ContinuousClock, Element> {
|
||||
throttle(for: interval, clock: .continuous, latest: latest)
|
||||
}
|
||||
}
|
||||
|
||||
/// A rate limited `AsyncSequence` by emitting values at most every specified interval.
|
||||
/// A rate-limited `AsyncSequence` by emitting values at most every specified interval.
|
||||
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
||||
public struct AsyncThrottleSequence<Base: AsyncSequence, C: Clock, Reduced> {
|
||||
let base: Base
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// A throwing channel for sending elements from on task to another with back pressure.
|
||||
/// An error-throwing channel for sending elements from on task to another with back pressure.
|
||||
///
|
||||
/// The `AsyncThrowingChannel` class is intended to be used as a communication types between tasks., particularly when one task produces values and another task consumes those values. The back pressure applied by `send(_:)`, `fail(_:)` and `finish()` via the suspension/resume ensure that the production of values does not exceed the consumption of values from iteration. Each of these methods suspends after enqueuing the event and is resumed when the next call to `next()` on the `Iterator` is made.
|
||||
/// The `AsyncThrowingChannel` class is intended to be used as a communication types between tasks, particularly when one task produces values and another task consumes those values. The back pressure applied by `send(_:)`, `fail(_:)` and `finish()` via suspension/resume ensures that the production of values does not exceed the consumption of values from iteration. Each of these methods suspends after enqueuing the event and is resumed when the next call to `next()` on the `Iterator` is made.
|
||||
public final class AsyncThrowingChannel<Element: Sendable, Failure: Error>: AsyncSequence, Sendable {
|
||||
/// The iterator for an `AsyncThrowingChannel` instance.
|
||||
public struct Iterator: AsyncIteratorProtocol, Sendable {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// Creates an asynchronous sequence that concurrently awaits values from two `AsyncSequence` types
|
||||
/// by emitting a tuple of the values.
|
||||
/// and emits a tuple of the values.
|
||||
public func zip<Base1: AsyncSequence, Base2: AsyncSequence>(_ base1: Base1, _ base2: Base2) -> AsyncZip2Sequence<Base1, Base2>
|
||||
where Base1: Sendable,
|
||||
Base2: Sendable,
|
||||
@@ -22,7 +22,7 @@ public func zip<Base1: AsyncSequence, Base2: AsyncSequence>(_ base1: Base1, _ ba
|
||||
}
|
||||
|
||||
/// An asynchronous sequence that concurrently awaits values from two `AsyncSequence` types
|
||||
/// by emitting a tuple of the values.
|
||||
/// and emits a tuple of the values.
|
||||
public struct AsyncZip2Sequence<Base1: AsyncSequence, Base2: AsyncSequence>: Sendable
|
||||
where Base1: Sendable,
|
||||
Base2: Sendable,
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// Creates an asynchronous sequence that concurrently awaits values from three `AsyncSequence` types
|
||||
/// by emitting a tuple of the values.
|
||||
/// and emits a tuple of the values.
|
||||
public func zip<Base1: AsyncSequence, Base2: AsyncSequence, Base3: AsyncSequence>(_ base1: Base1, _ base2: Base2, _ base3: Base3) -> AsyncZip3Sequence<Base1, Base2, Base3>
|
||||
where Base1: Sendable,
|
||||
Base2: Sendable,
|
||||
@@ -25,7 +25,7 @@ public func zip<Base1: AsyncSequence, Base2: AsyncSequence, Base3: AsyncSequence
|
||||
}
|
||||
|
||||
/// An asynchronous sequence that concurrently awaits values from three `AsyncSequence` types
|
||||
/// by emitting a tuple of the values.
|
||||
/// and emits a tuple of the values.
|
||||
public struct AsyncZip3Sequence<Base1: AsyncSequence, Base2: AsyncSequence, Base3: AsyncSequence>: Sendable
|
||||
where Base1: Sendable,
|
||||
Base2: Sendable,
|
||||
|
||||
Reference in new issue
Block a user