Skip to content

Commit 7b3fec3

Browse files
authored
add reference to piscina
Closes WiseLibs#914
1 parent b992d04 commit 7b3fec3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/threads.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
For most applications, `better-sqlite3` is fast enough to use in the main thread without blocking for a noticeable amount of time. However, if you need to perform very slow queries, you have the option of using [worker threads](https://nodejs.org/api/worker_threads.html) to keep things running smoothly. Below is an example of using a thread pool to perform queries in the background.
44

5+
NOTE: The example below is nice for simple use cases, but if you're going to do anything much more complex, then you may want to look into a proper worker library like [piscina](https://github.com/piscinajs/piscina).
6+
57
### worker.js
68

79
The worker logic is very simple in our case. It accepts messages from the master thread, executes each message's SQL (with any given parameters), and sends back the query results.

0 commit comments

Comments
 (0)