mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
DatabasePool.barrierWriteWithoutTransaction
This commit is contained in:
1 parent
473f6ff0d8
commit
8580023eda
1 file changed
+16
@@ -636,6 +636,22 @@ extension DatabasePool: DatabaseReader {
|
||||
return try writer.sync(updates)
|
||||
}
|
||||
|
||||
/// A barrier write ensures that no database access is executed until all
|
||||
/// previous accesses have completed, and the specified updates have been
|
||||
/// executed.
|
||||
///
|
||||
/// This method is *not* reentrant.
|
||||
///
|
||||
/// - important: Reads executed by concurrent *database snapshots* are not
|
||||
/// considered: they can run concurrently with the barrier updates.
|
||||
/// - parameter updates: The updates to the database.
|
||||
/// - throws: The error thrown by the updates.
|
||||
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
|
||||
return try readerPool.barrier {
|
||||
try writer.sync(updates)
|
||||
}
|
||||
}
|
||||
|
||||
/// Synchronously executes database updates in a protected dispatch queue,
|
||||
/// wrapped inside a transaction, and returns the result.
|
||||
///
|
||||
|
||||
Reference in new issue
Block a user