mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Now that user implementations of DatabaseWriter are no longer supported...
...stop pretending we have to implement concurrentRead on top of the deprecated readFromCurrentState. And this fixes #419 :-)
This commit is contained in:
1 parent
abe6957c85
commit
69853d7901
1 file changed
-31
@@ -187,37 +187,6 @@ extension DatabaseWriter {
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - Reading from Database
|
||||
|
||||
/// Default implementation, based on the deprecated readFromCurrentState.
|
||||
///
|
||||
/// :nodoc:
|
||||
public func concurrentRead<T>(_ block: @escaping (Database) throws -> T) -> Future<T> {
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
var result: Result<T>? = nil
|
||||
|
||||
do {
|
||||
try readFromCurrentState { db in
|
||||
result = Result { try block(db) }
|
||||
semaphore.signal()
|
||||
}
|
||||
} catch {
|
||||
result = .failure(error)
|
||||
semaphore.signal()
|
||||
}
|
||||
|
||||
return Future {
|
||||
_ = semaphore.wait(timeout: .distantFuture)
|
||||
|
||||
switch result! {
|
||||
case .failure(let error):
|
||||
throw error
|
||||
case .success(let result):
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Claiming Disk Space
|
||||
|
||||
/// Rebuilds the database file, repacking it into a minimal amount of
|
||||
|
||||
Reference in new issue
Block a user