diff --git a/GRDB/Documentation.docc/Concurrency.md b/GRDB/Documentation.docc/Concurrency.md index 6a23ab6de..3a736db92 100644 --- a/GRDB/Documentation.docc/Concurrency.md +++ b/GRDB/Documentation.docc/Concurrency.md @@ -222,11 +222,11 @@ Despite the common guarantees and rules shared by database queues and pools, tho ``DatabaseQueue`` opens a single database connection, and serializes all database accesses, reads, and writes. There is never more than one thread that uses the database. In the image below, we see how three threads can see the database as time passes: -![DatabaseQueueScheduling](https://cdn.rawgit.com/groue/GRDB.swift/master/Documentation/Images/DatabaseQueueScheduling.svg) +![DatabaseQueue Scheduling](DatabaseQueueScheduling.png) ``DatabasePool`` manages a pool of several database connections, and allows concurrent reads and writes thanks to the [WAL mode](https://www.sqlite.org/wal.html). A database pool serializes all writes (the guarantee). Reads are isolated so that they don't see changes performed by other threads (the guarantee). This gives a very different picture: -![DatabasePoolScheduling](https://cdn.rawgit.com/groue/GRDB.swift/master/Documentation/Images/DatabasePoolScheduling.svg) +![DatabasePool Scheduling](DatabasePoolScheduling.png) See how, with database pools, two reads can see different database states at the same time. This may look scary! Please see the next chapter below for a relief. @@ -330,7 +330,8 @@ Both ``DatabaseWriter/concurrentRead(_:)`` and ``DatabasePool/asyncConcurrentRea In the illustration below, the striped band shows the delay needed for the reading thread to acquire isolation. Until then, no other thread can write: -![DatabasePoolConcurrentRead](https://cdn.rawgit.com/groue/GRDB.swift/master/Documentation/Images/DatabasePoolConcurrentRead.svg) + +![DatabasePool Concurrent Read](DatabasePoolConcurrentRead.png) Types that conform to ``TransactionObserver`` can also use those methods in their ``TransactionObserver/databaseDidCommit(_:)`` method, in order to process database changes without blocking other threads that want to write into the database. diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead.png new file mode 100644 index 000000000..b43efb65f Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead@2x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead@2x.png new file mode 100644 index 000000000..ac496a711 Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead@2x.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead@3x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead@3x.png new file mode 100644 index 000000000..71f7d74bf Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead@3x.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead~dark.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead~dark.png new file mode 100644 index 000000000..cbcb4369c Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead~dark.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead~dark@2x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead~dark@2x.png new file mode 100644 index 000000000..5200abac7 Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead~dark@2x.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead~dark@3x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead~dark@3x.png new file mode 100644 index 000000000..6ee792551 Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolConcurrentRead~dark@3x.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling.png new file mode 100644 index 000000000..7f032381a Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling@2x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling@2x.png new file mode 100644 index 000000000..54059529e Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling@2x.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling@3x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling@3x.png new file mode 100644 index 000000000..40208bae0 Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling@3x.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling~dark.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling~dark.png new file mode 100644 index 000000000..17cd5d673 Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling~dark.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling~dark@2x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling~dark@2x.png new file mode 100644 index 000000000..64df1848e Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling~dark@2x.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling~dark@3x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling~dark@3x.png new file mode 100644 index 000000000..db3f7a8a6 Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabasePoolScheduling~dark@3x.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling.png new file mode 100644 index 000000000..b4bc5feeb Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling@2x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling@2x.png new file mode 100644 index 000000000..2edbdc6bd Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling@2x.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling@3x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling@3x.png new file mode 100644 index 000000000..95c482f7b Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling@3x.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling~dark.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling~dark.png new file mode 100644 index 000000000..8a8e2e5fd Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling~dark.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling~dark@2x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling~dark@2x.png new file mode 100644 index 000000000..445ebefbb Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling~dark@2x.png differ diff --git a/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling~dark@3x.png b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling~dark@3x.png new file mode 100644 index 000000000..0f11556c2 Binary files /dev/null and b/GRDB/Documentation.docc/Resources/concurrency-art/DatabaseQueueScheduling~dark@3x.png differ