Is Moor support for Multi-thread? #1187
Replies: 1 comment
-
It depends on what exactly you're doing across threads. In general, you can access the same database file across multiple isolates. When sqlite3 is compiled with thread-safety enabled, queries will have a consistent view across threads as you'd expect. However, some moor features that are built on top of sqlite3 apis require some setup to work across threads, mainly stream queries and migrations. For stream queries, you need to use a synchronization mechanism so that different isolates tell each other about updates they're making. This can be done with the isolates library provided by moor. That library makes it easy to have a single (background) isolate opening the database. Other isolates would then talk to the background isolate to send updates and synchronize streams. Apart from the slightly complicated setup, moor completely hides the fact that the database is running on another isolate. |
Beta Was this translation helpful? Give feedback.
-
Is the
Moor
support forMulti-thread
like inSQLite
?References: https://sqlite.org/threadsafe.html#:~:text=Multi%2Dthread.,in%20two%20or%20more%20threads
Beta Was this translation helpful? Give feedback.
All reactions