Skip to content

Commit dd42273

Browse files
committed
DatabasePool unsafeRead can access task locals
1 parent 69b786d commit dd42273

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

GRDB/Core/DatabasePool.swift

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -424,29 +424,10 @@ extension DatabasePool: DatabaseReader {
424424
throw DatabaseError.connectionIsClosed()
425425
}
426426

427-
let dbAccess = CancellableDatabaseAccess()
428-
return try await dbAccess.withCancellableContinuation { continuation in
429-
readerPool.asyncGet { result in
430-
do {
431-
let (reader, releaseReader) = try result.get()
432-
// Second async jump because that's how `Pool.async` has to be used.
433-
reader.async { db in
434-
defer {
435-
releaseReader(.reuse)
436-
}
437-
do {
438-
let result = try dbAccess.inDatabase(db) {
439-
try db.clearSchemaCacheIfNeeded()
440-
return try value(db)
441-
}
442-
continuation.resume(returning: result)
443-
} catch {
444-
continuation.resume(throwing: error)
445-
}
446-
}
447-
} catch {
448-
continuation.resume(throwing: error)
449-
}
427+
return try await readerPool.get { reader in
428+
try await reader.execute { db in
429+
try db.clearSchemaCacheIfNeeded()
430+
return try value(db)
450431
}
451432
}
452433
}

0 commit comments

Comments
 (0)