On this page
ControlSession.assumeIsolated(_:file:line:)
- Declared in
- ControlSession
- Package
- libtmux-swift
- assumeIsolated(_:file:line:) ( operation : (isolated Self) throws -> T , file : StaticString , line : UInt ) T
-
Assume that the current task is executing on this actor's serial executor, or stop program execution otherwise.
You call this method to *assume and verify* that the currently executing synchronous function is actually executing on the serial executor of this actor.
If that is the case, the operation is invoked with an
isolatedversion of the actor, 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, or if the actor is a reference to a remote actor, this method will crash with a fatal error (similar to
preconditionIsolated()).Note that this check is performed against the passed in actor's serial executor, meaning that if another actor uses the same serial executor--by using that actor's
Actor/unownedExecutoras its ownActor/unownedExecutor--this check will succeed, as from a concurrency safety perspective, the serial executor guarantees mutual exclusion of those two actors.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
Actor/unownedExecutor--this check will succeed , as from a concurrency safety perspective, the serial executor guarantees mutual exclusion of those two actors. - Parameters:
- operation: the operation that will be executed if the current context is executing on the actors serial executor.
- 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.
- Returns: the return value of the
operation - Throws: rethrows the
Errorthrown by the operation if it threw
- Raises
-
-
T
-
- 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
0 declared, 0 inherited