<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/SerialExecutor/checkIsolated()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Scf13checkIsolatedyyF"
  },
  "title" : "checkIsolated()"
}
-->

# checkIsolated()

Last resort “fallback” isolation check, called when the concurrency runtime
is comparing executors e.g. during [`assumeIsolated(_:file:line:)`](/documentation/Swift/Actor/assumeIsolated(_:file:line:))
and is unable to prove serial equivalence between the expected
(this object), and the current executor.

```
func checkIsolated()
```

## Discussion

During executor comparison, the Swift concurrency runtime attempts to compare
current and expected executors in a few ways (including “complex” equality
between executors (see [`isSameExclusiveExecutionContext(other:)`](/documentation/Swift/SerialExecutor/isSameExclusiveExecutionContext(other:))), and if all
those checks fail, this method is invoked on the expected executor.

This method MUST crash if it is unable to prove that the current execution
context belongs to this executor. At this point usual executor comparison would
have already failed, though the executor may have some external tracking of
threads it owns, and may be able to prove isolation nevertheless.

A default implementation is provided that unconditionally crashes the
program, and prevents calling code from proceeding with potentially
not thread-safe execution.

> Warning: This method must crash and halt program execution if unable
> to prove the isolation of the calling context.

---

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)