mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-22 04:00:39 +00:00
Optimize DatabasePool.currentReader
Suggested in https://github.com/groue/GRDB.swift/issues/1896
This commit is contained in:
1 parent
98c58f4eef
commit
b43260a17d
2 files changed
+5
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user