From dda8df678a49b60116e8e13784c2ba5a044c2905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 21 Sep 2016 09:15:27 +0200 Subject: [PATCH] Documentation --- GRDB/Core/SerializedDatabase.swift | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/GRDB/Core/SerializedDatabase.swift b/GRDB/Core/SerializedDatabase.swift index 633c92845..3e985cacd 100644 --- a/GRDB/Core/SerializedDatabase.swift +++ b/GRDB/Core/SerializedDatabase.swift @@ -73,22 +73,22 @@ final class SerializedDatabase { // } // } - if let watchdog = SchedulingWatchdog.current { - // Case 2 is forbidden. - GRDBPrecondition(!watchdog.allows(db), "Database methods are not reentrant.") - - // Case 3 - return try queue.sync { - try SchedulingWatchdog.current!.allowing(databases: watchdog.allowedDatabases) { - try block(db) - } - } - } else { + guard let watchdog = SchedulingWatchdog.current else { // Case 1 return try queue.sync { try block(db) } } + + // Case 2 is forbidden. + GRDBPrecondition(!watchdog.allows(db), "Database methods are not reentrant.") + + // Case 3 + return try queue.sync { + try SchedulingWatchdog.current!.allowing(databases: watchdog.allowedDatabases) { + try block(db) + } + } } /// Asynchronously executes a block in the serialized dispatch queue.