mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Combine and concurrency: lol
This commit is contained in:
1 parent
32ed290a1b
commit
1a3842e4bc
3 files changed
+16
-6
No files matched your search
@@ -201,7 +201,11 @@ extension DatabasePublishers {
|
||||
self.observation = observation
|
||||
}
|
||||
|
||||
public func receive<S>(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input {
|
||||
public func receive<S>(subscriber: S)
|
||||
where S: Subscriber & GRDBSendableMetatype,
|
||||
Failure == S.Failure,
|
||||
Output == S.Input
|
||||
{
|
||||
let subscription = DatabaseRegionSubscription(
|
||||
writer: writer,
|
||||
observation: observation,
|
||||
@@ -212,7 +216,7 @@ extension DatabasePublishers {
|
||||
|
||||
private class DatabaseRegionSubscription<Downstream>:
|
||||
Subscription, @unchecked Sendable
|
||||
where Downstream: Subscriber,
|
||||
where Downstream: Subscriber & GRDBSendableMetatype,
|
||||
Downstream.Failure == Error,
|
||||
Downstream.Input == Database
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ struct OnDemandFuture<Output, Failure: Error>: Publisher {
|
||||
self.attemptToFulfill = attemptToFulfill
|
||||
}
|
||||
|
||||
func receive<S>(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input {
|
||||
func receive<S>(subscriber: S) where S: Subscriber & GRDBSendableMetatype, Failure == S.Failure, Output == S.Input {
|
||||
let subscription = OnDemandFutureSubscription(
|
||||
attemptToFulfill: attemptToFulfill,
|
||||
downstream: subscriber)
|
||||
@@ -35,7 +35,9 @@ struct OnDemandFuture<Output, Failure: Error>: Publisher {
|
||||
}
|
||||
}
|
||||
|
||||
private class OnDemandFutureSubscription<Downstream: Subscriber>: Subscription, @unchecked Sendable {
|
||||
private class OnDemandFutureSubscription<Downstream>: Subscription, @unchecked Sendable
|
||||
where Downstream: Subscriber & GRDBSendableMetatype
|
||||
{
|
||||
// @unchecked because `state` is protected with `lock`.
|
||||
typealias Promise = @Sendable (Result<Downstream.Input, Downstream.Failure>) -> Void
|
||||
|
||||
|
||||
@@ -511,7 +511,11 @@ extension DatabasePublishers {
|
||||
self.start = start
|
||||
}
|
||||
|
||||
public func receive<S>(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input {
|
||||
public func receive<S>(subscriber: S)
|
||||
where S: Subscriber & GRDBSendableMetatype,
|
||||
Failure == S.Failure,
|
||||
Output == S.Input
|
||||
{
|
||||
let subscription = ValueSubscription(
|
||||
start: start,
|
||||
downstream: subscriber)
|
||||
@@ -521,7 +525,7 @@ extension DatabasePublishers {
|
||||
|
||||
private class ValueSubscription<Downstream>:
|
||||
Subscription, @unchecked Sendable
|
||||
where Downstream: Subscriber,
|
||||
where Downstream: Subscriber & GRDBSendableMetatype,
|
||||
Downstream.Failure == Error
|
||||
{
|
||||
// @unchecked Sendable because `cancellable` and `state` are
|
||||
|
||||
Reference in new issue
Block a user