Optimize DatabasePool.currentReader

Suggested in https://github.com/groue/GRDB.swift/issues/1896
This commit is contained in:
Gwendal Roué committed 2026-11-04 14:36:55 +01:00
1 parent 98c58f4eef
commit b43260a17d
2 files changed
+5

No files matched your search

+4
View File
@@ -659,6 +659,10 @@ extension DatabasePool: DatabaseReader {
/// Returns a reader that can be used from the current dispatch queue,
/// if any.
private var currentReader: SerializedDatabase? {
if SchedulingWatchdog.current == nil {
return nil
}
guard let readerPool else {
return nil
}
+1
View File
@@ -77,6 +77,7 @@ final class SchedulingWatchdog: @unchecked Sendable {
allowedDatabases.contains { $0 === db }
}
/// When nil, no database is allowed in the current execution context.
static var current: SchedulingWatchdog? {
DispatchQueue.getSpecific(key: watchDogKey)
}