<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/ContinuousClock/sleep(until:tolerance:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:12_Concurrency15ContinuousClockV5sleep5until9toleranceyAC7InstantV_s8DurationVSgtYaKF"
  },
  "title" : "sleep(until:tolerance:)"
}
-->

# sleep(until:tolerance:)

Suspend task execution until a given deadline within a tolerance.
If no tolerance is specified then the system may adjust the deadline
to coalesce CPU wake-ups to more efficiently process the wake-ups in
a more power efficient manner.

```
func sleep(until deadline: ContinuousClock.Instant, tolerance: Duration? = nil) async throws
```

## Discussion

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

This function doesn’t block the underlying thread.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)