mirror of
https://github.com/pointfreeco/swift-composable-architecture.git
synced 2025-12-24 12:14:25 +01:00
* `@preconcurrency @MainActor` isolation of `Store` * Remove unneeded `@MainActor`s * Remove thread checking code * Remove unneeded `@MainActor`s * Swift 5.10 compatibility fixes * wip * More 5.10 fixes * wip * fixes * wip * wip * up the timeout * wip * Fixes * wip * wip * wip * wip * wip * Fix binding action sendability * Address more binding action sendability * more bindable action sendability * more bindable action warnings * fix --------- Co-authored-by: Brandon Williams <mbrandonw@hey.com>
23 lines
522 B
Swift
23 lines
522 B
Swift
import Dispatch
|
|
|
|
func mainActorNow<R: Sendable>(execute block: @MainActor @Sendable () -> R) -> R {
|
|
if DispatchQueue.getSpecific(key: key) == value {
|
|
return MainActor._assumeIsolated {
|
|
block()
|
|
}
|
|
} else {
|
|
return DispatchQueue.main.sync {
|
|
MainActor._assumeIsolated {
|
|
block()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private let key: DispatchSpecificKey<UInt8> = {
|
|
let key = DispatchSpecificKey<UInt8>()
|
|
DispatchQueue.main.setSpecific(key: key, value: value)
|
|
return key
|
|
}()
|
|
private let value: UInt8 = 0
|