Skip to content

Instance MethodDispatch

scheduleOneshot(deadline:leeway:)

SwiftDeprecated

Deprecated

This symbol is deprecated.

Sets the deadline and leeway for a timer event that fires once.
func scheduleOneshot(deadline: DispatchTime, leeway: DispatchTimeInterval = .nanoseconds(0))

Parameters

deadline

The time at which the timer event will be delivered, subject to the leeway and other considerations described above. The deadline is based on Mach absolute time.

leeway

The leeway for the timer.

Discussion

Once this function returns, any pending source data accumulated for the previous timer values has been cleared and the next timer event will occur at deadline.

Delivery of the timer event may be delayed by the system in order to improve power consumption and system performance. The upper limit to the allowable delay may be configured with the leeway argument; the lower limit is under the control of the system.

The lower limit to the allowable delay may vary with process state such as visibility of the application UI. If the timer source was created with flags TimerFlags.strict, the system will make a best effort to strictly observe the provided leeway value, even if it is smaller than the current lower limit. Note that a minimal amount of delay is to be expected even if this flag is specified.

Calling this method has no effect if the timer source has already been canceled.

Note

Delivery of the timer event does not cancel the timer source.