This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Task where Success == Never, Failure == Never { | |
/// Suspends the current task for at least the given duration in seconds. | |
/// Throws if the task is cancelled while suspended. | |
/// - Parameter seconds: The sleep duration in seconds. | |
static func sleep(seconds: TimeInterval) async throws { | |
try await Task.sleep(nanoseconds: UInt64(seconds * 1_000_000_000)) | |
} | |
} |