Type MethodConcurrency


Suspends the current task for at least the given duration in nanoseconds.

  • Available when Success is Never and Failure is Never

  • iOS 13.0+
  • macOS 10.15+
  • tvOS 13.0+
  • watchOS 6.0+
static func sleep(nanoseconds duration: UInt64) async throws


If the task is canceled before the time ends, this function throws CancellationError.

This function doesn’t block the underlying thread.