Documentation

This commit is contained in:
Gwendal Roué committed 2016-12-05 09:13:45 +01:00
1 parent 8ad1d93cc6
commit 0793a0638e
1 file changed
+5 -3
+5 -3
View File
@@ -400,10 +400,12 @@ let poiCount = try dbPool.read { db in
Database pools allow several threads to access the database at the same time:
- When you don't need to modify the database, prefer the `read` method, because several threads can perform reads in parallel.
The total number of concurrent reads is limited. When the maximum number has been reached, a read waits for another read to complete. That maximum number can be configured (see below).
- The total number of concurrent reads is limited. When the maximum number has been reached, a read waits for another read to complete. That maximum number can be configured (see below).
- Conversely, writes are serialized. They still can happen in parallel with reads, but GRDB makes sure that those parallel writes are not visible inside a `read` closure.
- Conversely, writes are serialized. They don't block reads, but GRDB makes sure that `read` closures are guaranteed an immutable view of the last committed state of the database.
:point_up: When you need `read` closures to be guaranteed an immutable view of the last executed writing block as a whole, use `writeInTransaction` instead of `write`.
**A database pool needs your application to follow rules in order to deliver its safety guarantees.** Please refer to the [Concurrency](#concurrency) chapter.