StrictConcurrency: DatabaseRegionConvertible is Sendable

A ValueObservation will use such an object from database readers, writers, and the main thread: they must support all isolation domains.
This commit is contained in:
Gwendal Roué authored and Gwendal Roué committed 2024-07-27 16:37:33 +02:00
1 parent 8f486a5e41
commit b4677dede4
2 files changed
+9 -5

No files matched your search

+5 -4
View File
@@ -416,7 +416,7 @@ private struct TableRegion: Equatable {
/// ### Supporting Types
///
/// - ``AnyDatabaseRegionConvertible``
public protocol DatabaseRegionConvertible {
public protocol DatabaseRegionConvertible: Sendable {
/// Returns a database region.
///
/// - parameter db: A database connection.
@@ -437,14 +437,15 @@ extension DatabaseRegion: DatabaseRegionConvertible {
/// A type-erased DatabaseRegionConvertible
public struct AnyDatabaseRegionConvertible: DatabaseRegionConvertible {
let _region: (Database) throws -> DatabaseRegion
let _region: @Sendable (Database) throws -> DatabaseRegion
public init(_ region: @escaping (Database) throws -> DatabaseRegion) {
public init(_ region: @escaping @Sendable (Database) throws -> DatabaseRegion) {
_region = region
}
public init(_ region: some DatabaseRegionConvertible) {
_region = region.databaseRegion
// TODO: simplify when <https://github.com/apple/swift/issues/71541> is resolved.
_region = { try region.databaseRegion($0) }
}
public func databaseRegion(_ db: Database) throws -> DatabaseRegion {
+4 -1
View File
@@ -103,7 +103,7 @@
- [X] OnDemandFuture Sendable async closure
- [X] WALSnapshotTransaction refactor
- [X] anydatabasecancellable
- [ ] anydatabaseregionconvertible
- [X] anydatabaseregionconvertible
- [ ] anyfetchrequest
- [ ] anysqljsonexpressible
- [ ] association
@@ -176,6 +176,9 @@
- [X] transactionclock
- [ ] valueobservation
- [X] valueobservationscheduler
- [ ] ValueWriteOnlyObserver (needed so that it can conform to DatabaseCancellable)
- [ ] ValueObservationTrackingMode
- [X] DatabaseRegionConvertible
## Unsure if necessary