Skip to content

Commit

Permalink
NF: document that withCol and withQueue executes in IO (#13950)
Browse files Browse the repository at this point in the history
* NF: document that `withCol` and `withQueue` executes in IO

I had some doubt about which function moves to IO dispatcher, whether it was
launch method or withCol. I expect this documentation may save a minute to other
devs too.

* Update AnkiDroid/src/main/java/com/ichi2/anki/CollectionManager.kt

---------

Co-authored-by: Brayan Oliveira <69634269+BrayanDSO@users.noreply.github.com>
  • Loading branch information
Arthur-Milchior and BrayanDSO committed Jun 9, 2023
1 parent afcaf45 commit fcb4e25
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/anki/CollectionManager.kt
Expand Up @@ -58,8 +58,10 @@ object CollectionManager {
var emulateOpenFailure = false

/**
* Execute the provided block on a serial queue, to ensure concurrent access
* does not happen.
* Execute the provided block on a serial background queue, to ensure
* concurrent access does not happen.
*
* The background queue is run in a [Dispatchers.IO] context.
* It's important that the block is not suspendable - if it were, it would allow
* multiple requests to be interleaved when a suspend point was hit.
*
Expand Down Expand Up @@ -88,6 +90,8 @@ object CollectionManager {
/**
* Execute the provided block with the collection, opening if necessary.
*
* Calls are serialized, and run in background [Dispatchers.IO] thread.
*
* Parallel calls to this function are guaranteed to be serialized, so you can be
* sure the collection won't be closed or modified by another thread. This guarantee
* does not hold if legacy code calls [getColUnsafe].
Expand Down

0 comments on commit fcb4e25

Please sign in to comment.