Skip to content

Commit 1b7d4b0

Browse files
committed
Make throttle internal
# Motivation During the discussion in apple#248 it became clear that the semantics of `throttle` are not 100% figured out yet. # Modification This PR is making `throttle` internal to remove it from the upcoming 1.0.0 release. This gives us more time to investigate what exact semantics we want to have.
1 parent 281e27c commit 1b7d4b0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Sources/AsyncAlgorithms/AsyncThrottleSequence.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
extension AsyncSequence {
1313
/// Create a rate-limited `AsyncSequence` by emitting values at most every specified interval.
1414
@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
15-
public func throttle<C: Clock, Reduced>(for interval: C.Instant.Duration, clock: C, reducing: @Sendable @escaping (Reduced?, Element) async -> Reduced) -> AsyncThrottleSequence<Self, C, Reduced> {
15+
func throttle<C: Clock, Reduced>(for interval: C.Instant.Duration, clock: C, reducing: @Sendable @escaping (Reduced?, Element) async -> Reduced) -> AsyncThrottleSequence<Self, C, Reduced> {
1616
AsyncThrottleSequence(self, interval: interval, clock: clock, reducing: reducing)
1717
}
1818

1919
/// Create a rate-limited `AsyncSequence` by emitting values at most every specified interval.
2020
@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
21-
public func throttle<Reduced>(for interval: Duration, reducing: @Sendable @escaping (Reduced?, Element) async -> Reduced) -> AsyncThrottleSequence<Self, ContinuousClock, Reduced> {
21+
func throttle<Reduced>(for interval: Duration, reducing: @Sendable @escaping (Reduced?, Element) async -> Reduced) -> AsyncThrottleSequence<Self, ContinuousClock, Reduced> {
2222
throttle(for: interval, clock: .continuous, reducing: reducing)
2323
}
2424

2525
/// Create a rate-limited `AsyncSequence` by emitting values at most every specified interval.
2626
@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
27-
public func throttle<C: Clock>(for interval: C.Instant.Duration, clock: C, latest: Bool = true) -> AsyncThrottleSequence<Self, C, Element> {
27+
func throttle<C: Clock>(for interval: C.Instant.Duration, clock: C, latest: Bool = true) -> AsyncThrottleSequence<Self, C, Element> {
2828
throttle(for: interval, clock: clock) { previous, element in
2929
if latest {
3030
return element
@@ -36,14 +36,14 @@ extension AsyncSequence {
3636

3737
/// Create a rate-limited `AsyncSequence` by emitting values at most every specified interval.
3838
@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
39-
public func throttle(for interval: Duration, latest: Bool = true) -> AsyncThrottleSequence<Self, ContinuousClock, Element> {
39+
func throttle(for interval: Duration, latest: Bool = true) -> AsyncThrottleSequence<Self, ContinuousClock, Element> {
4040
throttle(for: interval, clock: .continuous, latest: latest)
4141
}
4242
}
4343

4444
/// A rate-limited `AsyncSequence` by emitting values at most every specified interval.
4545
@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
46-
public struct AsyncThrottleSequence<Base: AsyncSequence, C: Clock, Reduced> {
46+
struct AsyncThrottleSequence<Base: AsyncSequence, C: Clock, Reduced> {
4747
let base: Base
4848
let interval: C.Instant.Duration
4949
let clock: C
@@ -59,10 +59,10 @@ public struct AsyncThrottleSequence<Base: AsyncSequence, C: Clock, Reduced> {
5959

6060
@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
6161
extension AsyncThrottleSequence: AsyncSequence {
62-
public typealias Element = Reduced
62+
typealias Element = Reduced
6363

6464
/// The iterator for an `AsyncThrottleSequence` instance.
65-
public struct Iterator: AsyncIteratorProtocol {
65+
struct Iterator: AsyncIteratorProtocol {
6666
var base: Base.AsyncIterator
6767
var last: C.Instant?
6868
let interval: C.Instant.Duration
@@ -76,7 +76,7 @@ extension AsyncThrottleSequence: AsyncSequence {
7676
self.reducing = reducing
7777
}
7878

79-
public mutating func next() async rethrows -> Reduced? {
79+
mutating func next() async rethrows -> Reduced? {
8080
var reduced: Reduced?
8181
let start = last ?? clock.now
8282
repeat {
@@ -95,7 +95,7 @@ extension AsyncThrottleSequence: AsyncSequence {
9595
}
9696
}
9797

98-
public func makeAsyncIterator() -> Iterator {
98+
func makeAsyncIterator() -> Iterator {
9999
Iterator(base.makeAsyncIterator(), interval: interval, clock: clock, reducing: reducing)
100100
}
101101
}

0 commit comments

Comments
 (0)