DatabasePool.barrierWriteWithoutTransaction

This commit is contained in:
Gwendal Roué committed 2019-09-01 16:46:17 +02:00
1 parent 473f6ff0d8
commit 8580023eda
1 file changed
+16
+16
View File
@@ -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.
///