---
title: CheckedContinuation
framework: swift
role: symbol
role_heading: Structure
path: swift/checkedcontinuation
---

# CheckedContinuation

A mechanism to interface between synchronous and asynchronous code, logging correctness violations.

## Declaration

```swift
struct CheckedContinuation<T, E> where E : Error
```

## Overview

Overview A continuation is an opaque representation of program state. To create a continuation in asynchronous code, call the withCheckedContinuation(isolation:function:_:) or withCheckedThrowingContinuation(isolation:function:_:) function. To resume the asynchronous task, call the resume(returning:), resume(throwing:), resume(with:), or resume() method. important: You must call a resume method exactly once on every execution path throughout the program. Resuming from a continuation more than once is undefined behavior. Never resuming leaves the task in a suspended state indefinitely, and leaks any associated resources. CheckedContinuation logs a message if either of these invariants is violated. CheckedContinuation performs runtime checks for missing or multiple resume operations. UnsafeContinuation avoids enforcing these invariants at runtime because it aims to be a low-overhead mechanism for interfacing Swift tasks with event loops, delegate methods, callbacks, and other non-async scheduling mechanisms. However, during development, the ability to verify that the invariants are being upheld in testing is important. Because both types have the same interface, you can replace one with the other in most circumstances, without making other changes.

## Topics

### Initializers

- [init(continuation:function:)](swift/checkedcontinuation/init(continuation:function:).md)

### Instance Methods

- [resume()](swift/checkedcontinuation/resume().md)
- [resume(returning:)](swift/checkedcontinuation/resume(returning:).md)
- [resume(throwing:)](swift/checkedcontinuation/resume(throwing:).md)
- [resume(with:)](swift/checkedcontinuation/resume(with:)-3gh60.md)
- [resume(with:)](swift/checkedcontinuation/resume(with:)-5n1a5.md)

## Relationships

### Conforms To

- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Continuations

- [withCheckedContinuation(isolation:function:_:)](swift/withcheckedcontinuation(isolation:function:_:).md)
- [withCheckedThrowingContinuation(isolation:function:_:)](swift/withcheckedthrowingcontinuation(isolation:function:_:).md)
- [UnsafeContinuation](swift/unsafecontinuation.md)
- [withUnsafeContinuation(isolation:_:)](swift/withunsafecontinuation(isolation:_:).md)
- [UnsafeThrowingContinuation](swift/unsafethrowingcontinuation.md)
- [withUnsafeThrowingContinuation(isolation:_:)](swift/withunsafethrowingcontinuation(isolation:_:).md)
