mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Sendable annotations for OnDemandFuture
This commit is contained in:
1 parent
9a75127b15
commit
896d14ca56
1 file changed
+8
-4
@@ -14,9 +14,12 @@ import Foundation
|
||||
/// Both two extra scheduling guarantees are used by GRDB in order to be
|
||||
/// able to spawn concurrent database reads right from the database writer
|
||||
/// queue, and fulfill GRDB preconditions.
|
||||
///
|
||||
/// OnDemandFuture also adds Sendable requirements that avoid
|
||||
/// compiler warnings.
|
||||
@available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *)
|
||||
struct OnDemandFuture<Output, Failure: Error>: Publisher {
|
||||
typealias Promise = (Result<Output, Failure>) -> Void
|
||||
struct OnDemandFuture<Output: Sendable, Failure: Error>: Publisher {
|
||||
typealias Promise = @Sendable (Result<Output, Failure>) -> Void
|
||||
typealias Output = Output
|
||||
typealias Failure = Failure
|
||||
fileprivate let attemptToFulfill: (@escaping Promise) -> Void
|
||||
@@ -34,8 +37,9 @@ struct OnDemandFuture<Output, Failure: Error>: Publisher {
|
||||
}
|
||||
|
||||
@available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *)
|
||||
private class OnDemandFutureSubscription<Downstream: Subscriber>: Subscription {
|
||||
typealias Promise = (Result<Downstream.Input, Downstream.Failure>) -> Void
|
||||
private class OnDemandFutureSubscription<Downstream: Subscriber>: Subscription, @unchecked Sendable {
|
||||
// @unchecked because `state` is protected with `lock`.
|
||||
typealias Promise = @Sendable (Result<Downstream.Input, Downstream.Failure>) -> Void
|
||||
|
||||
private enum State {
|
||||
case waitingForDemand(downstream: Downstream, attemptToFulfill: (@escaping Promise) -> Void)
|
||||
|
||||
Reference in new issue
Block a user