Remove clock stubs and use the _Concurrency provided Clock APIs (#78)

* Remove the clock stubs

* Add default implementations using clocks
This commit is contained in:
Philippe Hausler authored and GitHub committed 2022-03-11 16:24:08 -08:00
1 parent 4b11faad62
commit 307118031e
12 files changed
+26 -1151

No files matched your search

@@ -13,6 +13,10 @@ extension AsyncSequence {
public func debounce<C: Clock>(for interval: C.Instant.Duration, tolerance: C.Instant.Duration? = nil, clock: C) -> AsyncDebounceSequence<Self, C> {
AsyncDebounceSequence(self, interval: interval, tolerance: tolerance, clock: clock)
}
public func debounce(for interval: Duration, tolerance: Duration? = nil) -> AsyncDebounceSequence<Self, ContinuousClock> {
debounce(for: interval, tolerance: tolerance, clock: .continuous)
}
}
public struct AsyncDebounceSequence<Base: AsyncSequence, C: Clock>: Sendable
@@ -14,11 +14,9 @@ extension AsyncSequence {
AsyncThrottleSequence(self, interval: interval, clock: clock, reducing: reducing)
}
/*
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)
}
*/
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
@@ -30,11 +28,9 @@ extension AsyncSequence {
}
}
/*
public func throttle(for interval: Duration, latest: Bool = true) -> AsyncThrottleSequence<Self, ContinuousClock, Element> {
throttle(for: interval, clock: .continuous, latest: latest)
}
*/
}
public struct AsyncThrottleSequence<Base: AsyncSequence, C: Clock, Reduced> {
@@ -73,13 +73,12 @@ extension AsyncTimerSequence {
}
}
/*
extension AsyncTimerSequence where C == SuspendingClock {
public static func repeating(every interval: Duration, tolerance: Duration? = nil) -> AsyncTimerSequence<SuspendingClock> {
return AsyncTimerSequence(interval: interval, tolerance: tolerance, clock: SuspendingClock())
}
}
*/
extension AsyncTimerSequence: Sendable { }
extension AsyncTimerSequence.Iterator: Sendable { }
-12
View File
@@ -1,12 +0,0 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Async Algorithms open source project
//
// Copyright (c) 2021 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
@_exported import ClockStub