Task

extension Task where Success == Never, Failure == Never

Available where Success == Never, Failure == Never

  • sleep(seconds:) Asynchronous

    Suspends the current task for at least the given duration in seconds.

    If the task is canceled before the time ends, this function throws CancellationError. This function doesn’t block the underlying thread.

    Declaration

    Swift

    public static func sleep(seconds duration: TimeInterval) async throws

    Parameters

    duration

    The number of seconds to suspend the current task for.