Skip to content

Commit

Permalink
Use isolated(any) instead of Sendable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonduenas committed Oct 23, 2024
1 parent 524fd4b commit 7373e40
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/ConcurrencyExtras/MainSerialExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
/// > during the operation.
///
/// - Parameter operation: An operation to be performed on the main serial executor.
#if compiler(>=6)
@MainActor
public func withMainSerialExecutor(
@_implicitSelfCapture operation: @isolated(any) () async throws -> Void
) async rethrows {
let didUseMainSerialExecutor = uncheckedUseMainSerialExecutor
defer { uncheckedUseMainSerialExecutor = didUseMainSerialExecutor }
uncheckedUseMainSerialExecutor = true
try await operation()
}
#else
@MainActor
public func withMainSerialExecutor(
@_implicitSelfCapture operation: @Sendable () async throws -> Void
Expand All @@ -36,6 +47,7 @@
uncheckedUseMainSerialExecutor = true
try await operation()
}
#endif

/// Perform an operation on the main serial executor.
///
Expand Down

0 comments on commit 7373e40

Please sign in to comment.