Instance Methodswift 6.0.1_Concurrency
sleep(for:tolerance:)
Suspends for the given duration.
- iOS
- 16.0+
- macOS
- 13.0+
- tvOS
- 16.0+
- watchOS
- 9.0+
func sleep(for duration: Self.Instant.Duration, tolerance: Self.Instant.Duration? = nil) async throws
Prefer to use the sleep(until:tolerance:)
method on Clock
if you have access to an absolute instant.
Other members in extension
Instance members
func measure(() throws -> Void
) rethrows -> Self.Instant.Duration Measure the elapsed time to execute a closure.
func measure(isolation: isolated (any Actor)?, () async throws -> Void
) async rethrows -> Self.Instant.Duration Measure the elapsed time to execute an asynchronous closure.