Skip to content

Commit fd1fa58

Browse files
committed
Revamp sendability."
1 parent f4281c5 commit fd1fa58

File tree

5 files changed

+83
-59
lines changed

5 files changed

+83
-59
lines changed

Examples/Examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let package = Package(
3333
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.9.0"),
3434
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.5.0"),
3535
.package(url: "https://github.com/pointfreeco/swift-sharing", from: "2.3.0"),
36-
.package(url: "https://github.com/pointfreeco/swift-structured-queries", from: "0.7.0"),
36+
.package(url: "https://github.com/pointfreeco/swift-structured-queries", branch: "default-main-actor"),
3737
],
3838
targets: [
3939
.target(

Sources/SharingGRDBCore/FetchAll.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public struct FetchAll<Element: Sendable>: Sendable {
114114
/// (`@Dependency(\.defaultDatabase)`).
115115
public init<V: QueryRepresentable>(
116116
wrappedValue: [Element] = [],
117-
_ statement: some StructuredQueriesCore.Statement<V>,
117+
_ statement: sending some StructuredQueriesCore.Statement<V>,
118118
database: (any DatabaseReader)? = nil
119119
)
120120
where
@@ -138,7 +138,7 @@ public struct FetchAll<Element: Sendable>: Sendable {
138138
/// (`@Dependency(\.defaultDatabase)`).
139139
public init<S: StructuredQueriesCore.Statement<Element>>(
140140
wrappedValue: [Element] = [],
141-
_ statement: S,
141+
_ statement: sending S,
142142
database: (any DatabaseReader)? = nil
143143
)
144144
where
@@ -181,7 +181,7 @@ public struct FetchAll<Element: Sendable>: Sendable {
181181
/// - database: The database to read from. A value of `nil` will use the default database
182182
/// (`@Dependency(\.defaultDatabase)`).
183183
public func load<V: QueryRepresentable>(
184-
_ statement: some StructuredQueriesCore.Statement<V>,
184+
_ statement: sending some StructuredQueriesCore.Statement<V>,
185185
database: (any DatabaseReader)? = nil
186186
) async throws
187187
where
@@ -249,7 +249,7 @@ extension FetchAll {
249249
/// asynchronously on the main queue.
250250
public init<V: QueryRepresentable>(
251251
wrappedValue: [Element] = [],
252-
_ statement: some StructuredQueriesCore.Statement<V>,
252+
_ statement: sending some StructuredQueriesCore.Statement<V>,
253253
database: (any DatabaseReader)? = nil,
254254
scheduler: some ValueObservationScheduler & Hashable
255255
)
@@ -277,7 +277,7 @@ extension FetchAll {
277277
/// asynchronously on the main queue.
278278
public init<S: StructuredQueriesCore.Statement<Element>>(
279279
wrappedValue: [Element] = [],
280-
_ statement: S,
280+
_ statement: sending S,
281281
database: (any DatabaseReader)? = nil,
282282
scheduler: some ValueObservationScheduler & Hashable
283283
)
@@ -327,7 +327,7 @@ extension FetchAll {
327327
/// - scheduler: The scheduler to observe from. By default, database observation is performed
328328
/// asynchronously on the main queue.
329329
public func load<V: QueryRepresentable>(
330-
_ statement: some StructuredQueriesCore.Statement<V>,
330+
_ statement: sending some StructuredQueriesCore.Statement<V>,
331331
database: (any DatabaseReader)? = nil,
332332
scheduler: some ValueObservationScheduler & Hashable
333333
) async throws
@@ -411,7 +411,7 @@ extension FetchAll: Equatable where Element: Equatable {
411411
/// the fetched results.
412412
public init<V: QueryRepresentable>(
413413
wrappedValue: [Element] = [],
414-
_ statement: some StructuredQueriesCore.Statement<V>,
414+
_ statement: sending some StructuredQueriesCore.Statement<V>,
415415
database: (any DatabaseReader)? = nil,
416416
animation: Animation
417417
)
@@ -437,7 +437,7 @@ extension FetchAll: Equatable where Element: Equatable {
437437
/// the fetched results.
438438
public init<S: StructuredQueriesCore.Statement<Element>>(
439439
wrappedValue: [Element] = [],
440-
_ statement: S,
440+
_ statement: sending S,
441441
database: (any DatabaseReader)? = nil,
442442
animation: Animation
443443
)
@@ -485,7 +485,7 @@ extension FetchAll: Equatable where Element: Equatable {
485485
/// - animation: The animation to use for user interface changes that result from changes to
486486
/// the fetched results.
487487
public func load<V: QueryRepresentable>(
488-
_ statement: some StructuredQueriesCore.Statement<V>,
488+
_ statement: sending some StructuredQueriesCore.Statement<V>,
489489
database: (any DatabaseReader)? = nil,
490490
animation: Animation
491491
) async throws
@@ -504,8 +504,11 @@ extension FetchAll: Equatable where Element: Equatable {
504504
}
505505
#endif
506506

507-
private struct FetchAllStatementValueRequest<Value: QueryRepresentable>: StatementKeyRequest {
507+
private struct FetchAllStatementValueRequest<Value: QueryRepresentable>: StatementKeyRequest, @unchecked Sendable {
508508
let statement: any StructuredQueriesCore.Statement<Value>
509+
init(statement: sending any StructuredQueriesCore.Statement<Value>) {
510+
self.statement = statement
511+
}
509512
func fetch(_ db: Database) throws -> [Value.QueryOutput] {
510513
try statement.fetchAll(db)
511514
}

0 commit comments

Comments
 (0)