Files

20 lines
595 B
Swift

// SPDX-FileCopyrightText: 2026 Kaede Akino
// SPDX-License-Identifier: GPL-3.0-only
import Foundation
public nonisolated struct MetricsClock: Sendable {
public var now: @Sendable () -> Date = { Date() }
public var sleep: @Sendable (TimeInterval) async throws -> Void = {
try await Task.sleep(for: .seconds($0))
}
public init(
now: @escaping @Sendable () -> Date = { Date() },
sleep: @escaping @Sendable (TimeInterval) async throws -> Void = { try await Task.sleep(for: .seconds($0)) }
) {
self.now = now
self.sleep = sleep
}
}