From 6dc4d50e001260cfab0ef5c28376abcd97d7b852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 12 Nov 2022 11:20:40 +0100 Subject: [PATCH] Expose Configuration.readQoS and writeQoS This helps tools that perform their own asynchronous jobs that depend on database scheduling. By using the same QoS as the database, they won't create priority inversion or similar scheduling misuses. --- GRDB/Core/Configuration.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/GRDB/Core/Configuration.swift b/GRDB/Core/Configuration.swift index bf3d17f03..f604890f5 100644 --- a/GRDB/Core/Configuration.swift +++ b/GRDB/Core/Configuration.swift @@ -46,6 +46,8 @@ import Foundation /// ### Configuring the Quality of Service /// /// - ``qos`` +/// - ``readQoS`` +/// - ``writeQoS`` /// - ``targetQueue`` /// - ``writeTargetQueue`` public struct Configuration { @@ -337,11 +339,16 @@ public struct Configuration { /// The default is `userInitiated`. public var qos: DispatchQoS = .userInitiated - /// The quality of service of read accesses - var readQoS: DispatchQoS { + /// The effective quality of service of read-only database accesses. + public var readQoS: DispatchQoS { targetQueue?.qos ?? self.qos } + /// The effective quality of service of write database accesses. + public var writeQoS: DispatchQoS { + writeTargetQueue?.qos ?? targetQueue?.qos ?? self.qos + } + /// The target dispatch queue for database accesses. /// /// Database connections which are not read-only will prefer