mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-09-10 11:51:49 +02:00
cleanup
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user