mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
OnDemandFuture fulfill is Sendable
This commit is contained in:
1 parent
f13b2d2eb4
commit
2aabc4c10e
3 files changed
+13
-8
No files matched your search
@@ -555,11 +555,9 @@ extension DatabaseReader {
|
|||||||
value: @escaping (Database) throws -> Output)
|
value: @escaping (Database) throws -> Output)
|
||||||
-> DatabasePublishers.Read<Output>
|
-> DatabasePublishers.Read<Output>
|
||||||
{
|
{
|
||||||
Deferred {
|
OnDemandFuture { fulfill in
|
||||||
Future { fulfill in
|
self.asyncRead { dbResult in
|
||||||
self.asyncRead { dbResult in
|
fulfill(dbResult.flatMap { db in Result { try value(db) } })
|
||||||
fulfill(dbResult.flatMap { db in Result { try value(db) } })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.receiveValues(on: scheduler)
|
.receiveValues(on: scheduler)
|
||||||
|
|||||||
@@ -14,9 +14,12 @@ import Foundation
|
|||||||
/// Both two extra scheduling guarantees are used by GRDB in order to be
|
/// Both two extra scheduling guarantees are used by GRDB in order to be
|
||||||
/// able to spawn concurrent database reads right from the database writer
|
/// able to spawn concurrent database reads right from the database writer
|
||||||
/// queue, and fulfill GRDB preconditions.
|
/// queue, and fulfill GRDB preconditions.
|
||||||
|
///
|
||||||
|
/// OnDemandFuture also adds Sendable requirements that avoid
|
||||||
|
/// compiler warnings.
|
||||||
@available(iOS 13, macOS 10.15, tvOS 13, *)
|
@available(iOS 13, macOS 10.15, tvOS 13, *)
|
||||||
struct OnDemandFuture<Output, Failure: Error>: Publisher {
|
struct OnDemandFuture<Output, Failure: Error>: Publisher {
|
||||||
typealias Promise = (Result<Output, Failure>) -> Void
|
typealias Promise = @Sendable (Result<Output, Failure>) -> Void
|
||||||
typealias Output = Output
|
typealias Output = Output
|
||||||
typealias Failure = Failure
|
typealias Failure = Failure
|
||||||
fileprivate let attemptToFulfill: (@escaping Promise) -> Void
|
fileprivate let attemptToFulfill: (@escaping Promise) -> Void
|
||||||
@@ -34,8 +37,9 @@ struct OnDemandFuture<Output, Failure: Error>: Publisher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS 13, macOS 10.15, tvOS 13, *)
|
@available(iOS 13, macOS 10.15, tvOS 13, *)
|
||||||
private class OnDemandFutureSubscription<Downstream: Subscriber>: Subscription {
|
private class OnDemandFutureSubscription<Downstream: Subscriber>: Subscription, @unchecked Sendable {
|
||||||
typealias Promise = (Result<Downstream.Input, Downstream.Failure>) -> Void
|
// @unchecked because `state` is protected with `lock`.
|
||||||
|
typealias Promise = @Sendable (Result<Downstream.Input, Downstream.Failure>) -> Void
|
||||||
|
|
||||||
private enum State {
|
private enum State {
|
||||||
case waitingForDemand(downstream: Downstream, attemptToFulfill: (@escaping Promise) -> Void)
|
case waitingForDemand(downstream: Downstream, attemptToFulfill: (@escaping Promise) -> Void)
|
||||||
|
|||||||
@@ -97,6 +97,9 @@
|
|||||||
- [X] GRDB7: All writes should be immediate, right? https://github.com/groue/GRDB.swift/pull/1485#issuecomment-1953793553
|
- [X] GRDB7: All writes should be immediate, right? https://github.com/groue/GRDB.swift/pull/1485#issuecomment-1953793553
|
||||||
- [X] GRDB7: Remove concurrenRead and DatabaseFuture
|
- [X] GRDB7: Remove concurrenRead and DatabaseFuture
|
||||||
- [ ] GRDB7: Sendable conformances
|
- [ ] GRDB7: Sendable conformances
|
||||||
|
- [ ] SerializedDatabase Sendable async closure
|
||||||
|
- [X] OnDemandFuture Sendable async closure
|
||||||
|
- [ ] WALSnapshotTransaction refactor
|
||||||
- [X] anydatabasecancellable
|
- [X] anydatabasecancellable
|
||||||
- [ ] anydatabaseregionconvertible
|
- [ ] anydatabaseregionconvertible
|
||||||
- [ ] anyfetchrequest
|
- [ ] anyfetchrequest
|
||||||
|
|||||||
Reference in new issue
Block a user