<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/SerialExecutor/isSameExclusiveExecutionContext(other:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Scf31isSameExclusiveExecutionContext5otherSbx_tF"
  },
  "title" : "isSameExclusiveExecutionContext(other:)"
}
-->

# isSameExclusiveExecutionContext(other:)

If this executor has complex equality semantics, and the runtime needs to
compare two executors, it will first attempt the usual pointer-based
equality / check, / and if it fails it will compare the types of both
executors, if they are the same, / it will finally invoke this method,
in an
attempt to let the executor itself decide / if this and the `other`
executor represent the same serial, exclusive, isolation context.

```
func isSameExclusiveExecutionContext(other: Self) -> Bool
```

## Parameters

`other`

the executor to compare with.

## Return Value

`true`, if `self` and the `other` executor actually are
mutually exclusive and it is safe–from a concurrency
perspective–to execute code assuming one on the other.

## Discussion

This method must be implemented with great care, as wrongly returning
`true` would allow / code from a different execution context (e.g. thread)
to execute code which was intended to be isolated by another actor.

This check is not used when performing executor switching.

This check is used when performing [`assertIsolated(_:file:line:)`](/documentation/Swift/Actor/assertIsolated(_:file:line:)),
[`preconditionIsolated(_:file:line:)`](/documentation/Swift/Actor/preconditionIsolated(_:file:line:)),
[`assumeIsolated(_:file:line:)`](/documentation/Swift/Actor/assumeIsolated(_:file:line:)) and similar APIs which assert about
the same “exclusive serial execution 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)