Function sleep(for:tolerance:options:)
public func sleep(
for duration: SchedulerTimeType.Stride,
tolerance: SchedulerTimeType.Stride = .zero,
options: SchedulerOptions? = nil
)
Suspends the current task for at least the given duration.
If the task is cancelled before the time ends, this function throws CancellationError
.
This function doesn't block the scheduler.
try await in scheduler.sleep(for: .seconds(1))
Parameters
Name | Type | Description |
---|---|---|
duration | SchedulerTimeType.Stride |
The time interval on which to sleep between yielding. |
tolerance | SchedulerTimeType.Stride |
The allowed timing variance when emitting events. Defaults to |
options | SchedulerOptions? |
Scheduler options passed to the timer. Defaults to |