Type MethodConcurrency


    Suspends the current task until the given deadline within a tolerance.

    • Available when Success is Never and Failure is Never

    • iOS 16.0+
    • macOS 13.0+
    • tvOS 16.0+
    • watchOS 9.0+
    static func sleep<C>(until deadline: C.Instant, tolerance: C.Instant.Duration? = nil, clock: C) async throws where C : Clock


    If the task is canceled before the time ends, this function throws CancellationError.

    This function doesn’t block the underlying thread.

      try await Task.sleep(until: .now + .seconds(3), clock: .continuous)