sleep(for:tolerance:clock:)
Suspends the current task for the given duration.
Declaration
static func sleep<C>(for duration: C.Instant.Duration, tolerance: C.Instant.Duration? = nil, clock: C = .continuous) async throws where C : ClockDiscussion
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(for: .seconds(3))