From ae8ffeabc99fbeeb7871bd98fb53286b6f9b38d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 12 Mar 2016 07:12:35 +0100 Subject: [PATCH] Cleanup --- GRDB/Core/Database.swift | 8 ++++---- GRDB/Core/SerializedDatabase.swift | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index c6f904de7..305670bc6 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -44,7 +44,7 @@ public final class Database { /// The value for the dispatch queue specific that holds the Database identity. /// See preconditionValidQueue. - var databaseQueueID: UnsafeMutablePointer = nil + var dispatchQueueID: UnsafeMutablePointer = nil init(path: String, configuration: Configuration, schemaCache: DatabaseSchemaCacheType) throws { self.configuration = configuration @@ -187,10 +187,10 @@ extension Database { /// The key for the dispatch queue specific that holds the Database identity. /// See preconditionValidQueue. - static let databaseQueueIDKey = unsafeBitCast(Database.self, UnsafePointer.self) // some unique pointer + static let dispatchQueueIDKey = unsafeBitCast(Database.self, UnsafePointer.self) // some unique pointer func preconditionValidQueue() { - precondition(databaseQueueID == nil || databaseQueueID == dispatch_get_specific(Database.databaseQueueIDKey), "Database was not used on the correct thread. If you get this error while iterating the result of a fetch() method, consider using the array returned by fetchAll() instead.") + precondition(dispatchQueueID == nil || dispatchQueueID == dispatch_get_specific(Database.dispatchQueueIDKey), "Database was not used on the correct thread. If you get this error while iterating the result of a fetch() method, consider using the array returned by fetchAll() instead.") } } @@ -1157,7 +1157,7 @@ public struct DatabaseEvent { /// The protocol for all types that can fetch values from a database. /// -/// It is adopted by DatabaseQueue, and DatabasePool, and Database. +/// It is adopted by DatabaseQueue, DatabasePool, and Database. /// /// You don't use the protocol directly. Instead, you provide a DatabaseReader /// to fetching methods: diff --git a/GRDB/Core/SerializedDatabase.swift b/GRDB/Core/SerializedDatabase.swift index a50e4727e..83e7db3a4 100644 --- a/GRDB/Core/SerializedDatabase.swift +++ b/GRDB/Core/SerializedDatabase.swift @@ -43,16 +43,16 @@ final class SerializedDatabase { self.queue = dispatch_queue_create("com.github.groue.GRDB", nil) // Activate database.preconditionValidQueue() - let databaseQueueID = unsafeBitCast(database, UnsafeMutablePointer.self) - dispatch_queue_set_specific(queue, Database.databaseQueueIDKey, databaseQueueID, nil) - database.databaseQueueID = databaseQueueID + let dispatchQueueID = unsafeBitCast(database, UnsafeMutablePointer.self) + dispatch_queue_set_specific(queue, Database.dispatchQueueIDKey, dispatchQueueID, nil) + database.dispatchQueueID = dispatchQueueID } func inDatabase(block: (db: Database) throws -> T) rethrows -> T { // This method is NOT reentrant. // // Avoiding dispatch_sync and calling block() right away if the specific - // is currently self.databaseQueueID looks like a promising solution: + // is currently self.dispatchQueueID looks like a promising solution: // // serializedDatabase.inDatabase { db in // serializedDatabase.inDatabase { db in @@ -73,7 +73,7 @@ final class SerializedDatabase { // // I try not to ship half-baked solutions, so until a complete solution // is found to this problem, I prefer discouraging reentrancy. - precondition(database.databaseQueueID != dispatch_get_specific(Database.databaseQueueIDKey), "Database methods are not reentrant.") + precondition(database.dispatchQueueID != dispatch_get_specific(Database.dispatchQueueIDKey), "Database methods are not reentrant.") return try dispatchSync(queue) { try block(db: self.database) }