This commit is contained in:
John Estropia
2026-07-24 11:51:36 +09:00
parent 1ea9ad7c4a
commit 13093d72d4
51 changed files with 1083 additions and 243 deletions
@@ -0,0 +1,31 @@
//
// WithMainActorImmediate.swift
// Demo
//
// Created by John Estropia on 2026/07/21.
//
import Foundation
// MARK: - withMainActorImmediate
func withMainActorImmediate(
_ task: @MainActor @Sendable @escaping () -> Void
) {
if #available(iOS 26.0, *) {
Task.immediate(operation: task)
}
else if Thread.isMainThread {
MainActor.assumeIsolated {
task()
}
}
else {
Task.init(operation: task)
}
}