diff --git a/Sources/ComposableArchitecture/Internal/DispatchQueue.swift b/Sources/ComposableArchitecture/Internal/DispatchQueue.swift index 33eedad7b9e0..db1e7409e7c1 100644 --- a/Sources/ComposableArchitecture/Internal/DispatchQueue.swift +++ b/Sources/ComposableArchitecture/Internal/DispatchQueue.swift @@ -1,24 +1,22 @@ -#if compiler(<6.2) - import Dispatch +import Dispatch - func mainActorNow(execute block: @MainActor @Sendable () -> R) -> R { - if DispatchQueue.getSpecific(key: key) == value { - return MainActor._assumeIsolated { +func mainActorNow(execute block: @MainActor @Sendable () -> R) -> R { + if DispatchQueue.getSpecific(key: key) == value { + return MainActor._assumeIsolated { + block() + } + } else { + return DispatchQueue.main.sync { + MainActor._assumeIsolated { block() } - } else { - return DispatchQueue.main.sync { - MainActor._assumeIsolated { - block() - } - } } } +} - private let key: DispatchSpecificKey = { - let key = DispatchSpecificKey() - DispatchQueue.main.setSpecific(key: key, value: value) - return key - }() - private let value: UInt8 = 0 -#endif +private let key: DispatchSpecificKey = { + let key = DispatchSpecificKey() + DispatchQueue.main.setSpecific(key: key, value: value) + return key +}() +private let value: UInt8 = 0