diff --git a/GRDB/Utils/OnDemandFuture.swift b/GRDB/Utils/OnDemandFuture.swift index 6826014a4..affc4f083 100644 --- a/GRDB/Utils/OnDemandFuture.swift +++ b/GRDB/Utils/OnDemandFuture.swift @@ -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: Publisher { - typealias Promise = (Result) -> Void +struct OnDemandFuture: Publisher { + typealias Promise = @Sendable (Result) -> Void typealias Output = Output typealias Failure = Failure fileprivate let attemptToFulfill: (@escaping Promise) -> Void @@ -34,8 +37,9 @@ struct OnDemandFuture: Publisher { } @available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *) -private class OnDemandFutureSubscription: Subscription { - typealias Promise = (Result) -> Void +private class OnDemandFutureSubscription: Subscription, @unchecked Sendable { + // @unchecked because `state` is protected with `lock`. + typealias Promise = @Sendable (Result) -> Void private enum State { case waitingForDemand(downstream: Downstream, attemptToFulfill: (@escaping Promise) -> Void)