Skip to content

Commit 1a3842e

Browse files
committed
Combine and concurrency: lol
1 parent 32ed290 commit 1a3842e

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

GRDB/Core/DatabaseRegionObservation.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ extension DatabasePublishers {
201201
self.observation = observation
202202
}
203203

204-
public func receive<S>(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input {
204+
public func receive<S>(subscriber: S)
205+
where S: Subscriber & GRDBSendableMetatype,
206+
Failure == S.Failure,
207+
Output == S.Input
208+
{
205209
let subscription = DatabaseRegionSubscription(
206210
writer: writer,
207211
observation: observation,
@@ -212,7 +216,7 @@ extension DatabasePublishers {
212216

213217
private class DatabaseRegionSubscription<Downstream>:
214218
Subscription, @unchecked Sendable
215-
where Downstream: Subscriber,
219+
where Downstream: Subscriber & GRDBSendableMetatype,
216220
Downstream.Failure == Error,
217221
Downstream.Input == Database
218222
{

GRDB/Utils/OnDemandFuture.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@ struct OnDemandFuture<Output, Failure: Error>: Publisher {
2727
self.attemptToFulfill = attemptToFulfill
2828
}
2929

30-
func receive<S>(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input {
30+
func receive<S>(subscriber: S) where S: Subscriber & GRDBSendableMetatype, Failure == S.Failure, Output == S.Input {
3131
let subscription = OnDemandFutureSubscription(
3232
attemptToFulfill: attemptToFulfill,
3333
downstream: subscriber)
3434
subscriber.receive(subscription: subscription)
3535
}
3636
}
3737

38-
private class OnDemandFutureSubscription<Downstream: Subscriber>: Subscription, @unchecked Sendable {
38+
private class OnDemandFutureSubscription<Downstream>: Subscription, @unchecked Sendable
39+
where Downstream: Subscriber & GRDBSendableMetatype
40+
{
3941
// @unchecked because `state` is protected with `lock`.
4042
typealias Promise = @Sendable (Result<Downstream.Input, Downstream.Failure>) -> Void
4143

GRDB/ValueObservation/ValueObservation.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,11 @@ extension DatabasePublishers {
511511
self.start = start
512512
}
513513

514-
public func receive<S>(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input {
514+
public func receive<S>(subscriber: S)
515+
where S: Subscriber & GRDBSendableMetatype,
516+
Failure == S.Failure,
517+
Output == S.Input
518+
{
515519
let subscription = ValueSubscription(
516520
start: start,
517521
downstream: subscriber)
@@ -521,7 +525,7 @@ extension DatabasePublishers {
521525

522526
private class ValueSubscription<Downstream>:
523527
Subscription, @unchecked Sendable
524-
where Downstream: Subscriber,
528+
where Downstream: Subscriber & GRDBSendableMetatype,
525529
Downstream.Failure == Error
526530
{
527531
// @unchecked Sendable because `cancellable` and `state` are

0 commit comments

Comments
 (0)