Function sleep(until:tolerance:options:)
public func sleep(
until deadline: SchedulerTimeType,
tolerance: SchedulerTimeType.Stride = .zero,
options: SchedulerOptions? = nil
)
Suspend task execution until a given deadline within a tolerance.
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(until: scheduler.now + .seconds(1))
Parameters
Name | Type | Description |
---|---|---|
deadline | SchedulerTimeType |
An instant of time to suspend until. |
tolerance | SchedulerTimeType.Stride |
The allowed timing variance when emitting events. Defaults to |
options | SchedulerOptions? |
Scheduler options passed to the timer. Defaults to |