withSerialExecutor(_:)
Perform an operation with the actor’s Serialexecutor.
Declaration
nonisolated func withSerialExecutor<T, E>(_ operation: nonisolated(nonsending) (any SerialExecutor) async throws(E) -> T) async throws(E) -> T where E : Error, T : ~CopyableDiscussion
This converts the actor’s unownedExecutor to a SerialExecutor while retaining the actor for the duration of the operation. This is to ensure the lifetime of the executor while performing the operation.