Skip to content

Commit d242421

Browse files
committed
Async methods accept a non-escaping closure
1 parent 7a1e65b commit d242421

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

GRDB/Core/DatabasePool.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ extension DatabasePool: DatabaseReader {
352352
}
353353

354354
public func read<T: Sendable>(
355-
_ value: @escaping @Sendable (Database) throws -> T
355+
_ value: @Sendable (Database) throws -> T
356356
) async throws -> T {
357357
guard let readerPool else {
358358
throw DatabaseError.connectionIsClosed()
@@ -422,7 +422,7 @@ extension DatabasePool: DatabaseReader {
422422
}
423423

424424
public func unsafeRead<T: Sendable>(
425-
_ value: @escaping @Sendable (Database) throws -> T
425+
_ value: @Sendable (Database) throws -> T
426426
) async throws -> T {
427427
guard let readerPool else {
428428
throw DatabaseError.connectionIsClosed()
@@ -771,7 +771,7 @@ extension DatabasePool: DatabaseWriter {
771771
}
772772

773773
public func writeWithoutTransaction<T: Sendable>(
774-
_ updates: @escaping @Sendable (Database) throws -> T
774+
_ updates: @Sendable (Database) throws -> T
775775
) async throws -> T {
776776
try await writer.execute(updates)
777777
}
@@ -787,7 +787,7 @@ extension DatabasePool: DatabaseWriter {
787787
}
788788

789789
public func barrierWriteWithoutTransaction<T: Sendable>(
790-
_ updates: @escaping @Sendable (Database) throws -> T
790+
_ updates: @Sendable (Database) throws -> T
791791
) async throws -> T {
792792
guard let readerPool else {
793793
throw DatabaseError.connectionIsClosed()

GRDB/Core/DatabaseQueue.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ extension DatabaseQueue: DatabaseReader {
234234
}
235235

236236
public func read<T: Sendable>(
237-
_ value: @escaping @Sendable (Database) throws -> T
237+
_ value: @Sendable (Database) throws -> T
238238
) async throws -> T {
239239
try await writer.execute { db in
240240
try db.isolated(readOnly: true) {
@@ -273,7 +273,7 @@ extension DatabaseQueue: DatabaseReader {
273273
}
274274

275275
public func unsafeRead<T: Sendable>(
276-
_ value: @escaping @Sendable (Database) throws -> T
276+
_ value: @Sendable (Database) throws -> T
277277
) async throws -> T {
278278
try await writer.execute(value)
279279
}
@@ -387,7 +387,7 @@ extension DatabaseQueue: DatabaseWriter {
387387
}
388388

389389
public func writeWithoutTransaction<T: Sendable>(
390-
_ updates: @escaping @Sendable (Database) throws -> T
390+
_ updates: @Sendable (Database) throws -> T
391391
) async throws -> T {
392392
try await writer.execute(updates)
393393
}
@@ -398,7 +398,7 @@ extension DatabaseQueue: DatabaseWriter {
398398
}
399399

400400
public func barrierWriteWithoutTransaction<T: Sendable>(
401-
_ updates: @escaping @Sendable (Database) throws -> T
401+
_ updates: @Sendable (Database) throws -> T
402402
) async throws -> T {
403403
try await writer.execute(updates)
404404
}

GRDB/Core/DatabaseReader.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ import Dispatch
2222
/// ### Reading from the Database
2323
///
2424
/// - ``read(_:)-3806d``
25-
/// - ``read(_:)-4d1da``
25+
/// - ``read(_:)-5mfwu``
2626
/// - ``readPublisher(receiveOn:value:)``
2727
/// - ``asyncRead(_:)``
2828
///
2929
/// ### Unsafe Methods
3030
///
3131
/// - ``unsafeRead(_:)-5i7tf``
32-
/// - ``unsafeRead(_:)-5gsav``
32+
/// - ``unsafeRead(_:)-90w0p``
3333
/// - ``unsafeReentrantRead(_:)``
3434
/// - ``asyncUnsafeRead(_:)``
3535
///
@@ -215,7 +215,7 @@ public protocol DatabaseReader: AnyObject, Sendable {
215215
/// database access, or the error thrown by `value`, or
216216
/// `CancellationError` if the task is cancelled.
217217
func read<T: Sendable>(
218-
_ value: @escaping @Sendable (Database) throws -> T
218+
_ value: @Sendable (Database) throws -> T
219219
) async throws -> T
220220

221221
/// Schedules read-only database operations for execution, and
@@ -319,7 +319,7 @@ public protocol DatabaseReader: AnyObject, Sendable {
319319
/// database access, or the error thrown by `value`, or
320320
/// `CancellationError` if the task is cancelled.
321321
func unsafeRead<T: Sendable>(
322-
_ value: @escaping @Sendable (Database) throws -> T
322+
_ value: @Sendable (Database) throws -> T
323323
) async throws -> T
324324

325325
/// Schedules database operations for execution, and returns immediately.
@@ -652,7 +652,7 @@ extension AnyDatabaseReader: DatabaseReader {
652652
}
653653

654654
public func read<T: Sendable>(
655-
_ value: @escaping @Sendable (Database) throws -> T
655+
_ value: @Sendable (Database) throws -> T
656656
) async throws -> T {
657657
try await base.read(value)
658658
}
@@ -669,7 +669,7 @@ extension AnyDatabaseReader: DatabaseReader {
669669
}
670670

671671
public func unsafeRead<T: Sendable>(
672-
_ value: @escaping @Sendable (Database) throws -> T
672+
_ value: @Sendable (Database) throws -> T
673673
) async throws -> T {
674674
try await base.unsafeRead(value)
675675
}

GRDB/Core/DatabaseSnapshot.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ extension DatabaseSnapshot: DatabaseSnapshotReader {
154154
}
155155

156156
public func read<T: Sendable>(
157-
_ value: @escaping @Sendable (Database) throws -> T
157+
_ value: @Sendable (Database) throws -> T
158158
) async throws -> T {
159159
try await reader.execute(value)
160160
}
@@ -175,7 +175,7 @@ extension DatabaseSnapshot: DatabaseSnapshotReader {
175175
// `DatabaseSnapshotReader`, because of
176176
// <https://github.com/apple/swift/issues/74469>.
177177
public func unsafeRead<T: Sendable>(
178-
_ value: @escaping @Sendable (Database) throws -> T
178+
_ value: @Sendable (Database) throws -> T
179179
) async throws -> T {
180180
try await read(value)
181181
}

GRDB/Core/DatabaseSnapshotPool.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ extension DatabaseSnapshotPool: DatabaseSnapshotReader {
294294
}
295295

296296
public func read<T: Sendable>(
297-
_ value: @escaping @Sendable (Database) throws -> T
297+
_ value: @Sendable (Database) throws -> T
298298
) async throws -> T {
299299
guard let readerPool else {
300300
throw DatabaseError.connectionIsClosed()
@@ -342,7 +342,7 @@ extension DatabaseSnapshotPool: DatabaseSnapshotReader {
342342
// `DatabaseSnapshotReader`, because of
343343
// <https://github.com/apple/swift/issues/74469>.
344344
public func unsafeRead<T: Sendable>(
345-
_ value: @escaping @Sendable (Database) throws -> T
345+
_ value: @Sendable (Database) throws -> T
346346
) async throws -> T {
347347
try await read(value)
348348
}

GRDB/Core/DatabaseWriter.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ import Dispatch
2222
/// ### Writing into the Database
2323
///
2424
/// - ``write(_:)-76inz``
25-
/// - ``write(_:)-3db50``
25+
/// - ``write(_:)-4gnqx``
2626
/// - ``writePublisher(receiveOn:updates:)``
2727
/// - ``writePublisher(receiveOn:updates:thenRead:)``
2828
/// - ``writeWithoutTransaction(_:)-4qh1w``
29-
/// - ``writeWithoutTransaction(_:)-67mri``
29+
/// - ``writeWithoutTransaction(_:)-18zhj``
3030
/// - ``asyncWrite(_:completion:)``
3131
/// - ``asyncWriteWithoutTransaction(_:)``
3232
///
3333
/// ### Exclusive Access to the Database
3434
///
3535
/// - ``barrierWriteWithoutTransaction(_:)-280j1``
36-
/// - ``barrierWriteWithoutTransaction(_:)-48d63``
36+
/// - ``barrierWriteWithoutTransaction(_:)-11q6c``
3737
/// - ``asyncBarrierWriteWithoutTransaction(_:)``
3838
///
3939
/// ### Reading from the Latest Committed Database State
@@ -130,7 +130,7 @@ public protocol DatabaseWriter: DatabaseReader {
130130
/// database access, or the error thrown by `updates`, or
131131
/// `CancellationError` if the task is cancelled.
132132
func writeWithoutTransaction<T: Sendable>(
133-
_ updates: @escaping @Sendable (Database) throws -> T
133+
_ updates: @Sendable (Database) throws -> T
134134
) async throws -> T
135135

136136
/// Executes database operations, and returns their result after they have
@@ -213,7 +213,7 @@ public protocol DatabaseWriter: DatabaseReader {
213213
/// database access, or the error thrown by `updates`, or
214214
/// `CancellationError` if the task is cancelled.
215215
func barrierWriteWithoutTransaction<T: Sendable>(
216-
_ updates: @escaping @Sendable (Database) throws -> T
216+
_ updates: @Sendable (Database) throws -> T
217217
) async throws -> T
218218

219219
/// Schedules database operations for execution, and returns immediately.
@@ -640,7 +640,7 @@ extension DatabaseWriter {
640640
/// database access, or the error thrown by `updates`, or
641641
/// `CancellationError` if the task is cancelled.
642642
public func write<T: Sendable>(
643-
_ updates: @escaping @Sendable (Database) throws -> T
643+
_ updates: @Sendable (Database) throws -> T
644644
) async throws -> T {
645645
try await writeWithoutTransaction { db in
646646
var result: T?
@@ -885,7 +885,7 @@ extension AnyDatabaseWriter: DatabaseReader {
885885
}
886886

887887
public func read<T: Sendable>(
888-
_ value: @escaping @Sendable (Database) throws -> T
888+
_ value: @Sendable (Database) throws -> T
889889
) async throws -> T {
890890
try await base.read(value)
891891
}
@@ -902,7 +902,7 @@ extension AnyDatabaseWriter: DatabaseReader {
902902
}
903903

904904
public func unsafeRead<T: Sendable>(
905-
_ value: @escaping @Sendable (Database) throws -> T
905+
_ value: @Sendable (Database) throws -> T
906906
) async throws -> T {
907907
try await base.unsafeRead(value)
908908
}
@@ -936,7 +936,7 @@ extension AnyDatabaseWriter: DatabaseWriter {
936936
}
937937

938938
public func writeWithoutTransaction<T: Sendable>(
939-
_ updates: @escaping @Sendable (Database) throws -> T
939+
_ updates: @Sendable (Database) throws -> T
940940
) async throws -> T {
941941
try await base.writeWithoutTransaction(updates)
942942
}
@@ -947,7 +947,7 @@ extension AnyDatabaseWriter: DatabaseWriter {
947947
}
948948

949949
public func barrierWriteWithoutTransaction<T: Sendable>(
950-
_ updates: @escaping @Sendable (Database) throws -> T
950+
_ updates: @Sendable (Database) throws -> T
951951
) async throws -> T {
952952
try await base.barrierWriteWithoutTransaction(updates)
953953
}

GRDB/Documentation.docc/Concurrency.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ try dbQueue.write { db in
9797
}
9898
```
9999

100-
See ``DatabaseReader/read(_:)-4d1da`` and ``DatabaseWriter/write(_:)-3db50``.
100+
See ``DatabaseReader/read(_:)-5mfwu`` and ``DatabaseWriter/write(_:)-4gnqx``.
101101

102102
Note the identical method names: `read`, `write`. The async version is only available in async Swift functions.
103103

0 commit comments

Comments
 (0)