From 66c2b72a28152d9cd16f23f54567dbbd1b95e495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Mon, 19 Jun 2017 13:02:43 +0200 Subject: [PATCH] Database.afterNextTransactionCommit(_:): document that the closure runs in a protected dispatch queue --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85644376f..3cd50f577 100644 --- a/README.md +++ b/README.md @@ -4074,9 +4074,9 @@ Database observation requires that a single [database queue](#database-queues) o ### After Commit Hook -**When an application needs to make sure a database transaction has been successfully committed before it executes some work, use the `Database.afterNextTransactionCommit(_:)` method.** +**When your application needs to make sure a database transaction has been successfully committed before it executes some work, use the `Database.afterNextTransactionCommit(_:)` method.** -Its closure argument is called after database changes have been successfully written to disk: +Its closure argument is called right after database changes have been successfully written to disk: ```swift dbQueue.inTransaction { db in @@ -4088,6 +4088,8 @@ dbQueue.inTransaction { db in } ``` +The closure runs in a protected dispatch queue, serialized with all database updates. + **This "after commit hook" helps synchronizing the database with other resources, such as files, or system sensors.** In the example below, a [location manager](https://developer.apple.com/documentation/corelocation/cllocationmanager) starts monitoring a CLRegion if and only if it has successfully been stored in the database: