-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make 'didSet' main actor. * tests for AppStorageKey * wip * tests * clean up * Update Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKey.swift * Update Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKeyPathKey.swift * try working around CI problem * Added NB * wip * Update MigratingTo1.11.md --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com>
- Loading branch information
1 parent
a200f6a
commit 54eb417
Showing
10 changed files
with
163 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Sources/ComposableArchitecture/Internal/DispatchQueue.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Dispatch | ||
|
||
func mainActorASAP(execute block: @escaping @MainActor @Sendable () -> Void) { | ||
if DispatchQueue.getSpecific(key: key) == value { | ||
assumeMainActorIsolated { | ||
block() | ||
} | ||
} else { | ||
DispatchQueue.main.async { | ||
block() | ||
} | ||
} | ||
} | ||
|
||
private let key: DispatchSpecificKey<UInt8> = { | ||
let key = DispatchSpecificKey<UInt8>() | ||
DispatchQueue.main.setSpecific(key: key, value: value) | ||
return key | ||
}() | ||
private let value: UInt8 = 0 | ||
|
||
// NB: Currently we can't use 'MainActor.assumeIsolated' on CI, but we can approximate this in | ||
// the meantime. | ||
@MainActor(unsafe) | ||
private func assumeMainActorIsolated(_ block: @escaping @MainActor @Sendable () -> Void) { | ||
block() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters