Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions Sources/ComposableArchitecture/Internal/DispatchQueue.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
#if compiler(<6.2)
import Dispatch
import Dispatch

func mainActorNow<R: Sendable>(execute block: @MainActor @Sendable () -> R) -> R {
if DispatchQueue.getSpecific(key: key) == value {
return MainActor._assumeIsolated {
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()
}
} 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
#endif
private let key: DispatchSpecificKey<UInt8> = {
let key = DispatchSpecificKey<UInt8>()
DispatchQueue.main.setSpecific(key: key, value: value)
return key
}()
private let value: UInt8 = 0
Loading