import Foundation
/// Monotonic time and sleeping, injectable so poll loops are testable.
public protocol IrdClock: Sendable {
/// Monotonic elapsed time since an arbitrary origin.
var now: Duration { get }
func sleep(for duration: Duration) async throws
}
public struct SystemClock: IrdClock {
private let origin = ContinuousClock.now
public init() {}
public var now: Duration { ContinuousClock.now - origin }
public func sleep(for duration: Duration) async throws {
try await Task.sleep(for: duration, clock: .continuous)
}
}