<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Distributed/DistributedActor/assumeIsolated(_:file:line:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Distributed"
    ],
    "preciseIdentifier" : "s:11Distributed0A5ActorPAAE14assumeIsolated_4file4lineqd__qd__xYiKXE_s12StaticStringVSutKs8SendableRd__lF"
  },
  "title" : "assumeIsolated(_:file:line:)"
}
-->

# assumeIsolated(_:file:line:)

Assume that the current task is executing on this (local) distributed
actor’s serial executor, or stop program execution otherwise.

```
nonisolated func assumeIsolated<T>(_ operation: (isolated Self) throws -> T, file: StaticString = #fileID, line: UInt = #line) rethrows -> T where T : Sendable
```

## Parameters

`operation`

the operation that will be executed if the current context
is executing on the actors serial executor, and the actor
is a local reference.

`file`

The file name to print if the assertion fails. The default is
where this method was called.

`line`

The line number to print if the assertion fails The default is
where this method was called.

## Return Value

the return value of the `operation`

## Discussion

This method allows to *assume and verify* that the currently
executing synchronous function is actually executing on the serial
executor of the this (local) distributed actor.

If that is the case, the operation is invoked isolated to the main actor
(`@MainActor () -> T`), allowing synchronous access to actor local state
without hopping through asynchronous boundaries.

If the current context is not running on the actor’s serial executor,
this method will crash with a fatal error (similar
to [`preconditionIsolated(_:file:line:)`](/documentation/Distributed/DistributedActor/preconditionIsolated(_:file:line:))).

This method can only be used from synchronous functions, as asynchronous
functions should instead perform a normal method call to the actor, which
will hop task execution to the target actor if necessary.

> Note: This check is performed against the actor’s serial executor,
> meaning that / if another actor uses the same serial executor–by using
> another actor’s executor as its own ``doc://com.apple.Swift/documentation/Distributed/DistributedActor/unownedExecutor``
> –this check will succeed , as from a concurrency safety perspective,
> the serial executor guarantees mutual exclusion of those two actors.

> Throws: rethrows the `Error` thrown by the operation if it threw

---

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)