Re:Better-sqlite3: A faster Sqlite library for Node.js
by zbjornson on Monday March 19, 2018 @11:48AM
(#16619305)
What signatures are you referring to? They all take async callbacks.
Re:Better-sqlite3: A faster Sqlite library for Node.js
by always_good on Monday March 19, 2018 @12:17PM
(#16619570)
Yes, and that's not an synchronous API.
For example, https://nodejs.org/api/crypto.html#crypto_crypto_randombytes... without the callback blocks.
You said "Just because SQLite's API is synchronous does not mean that it must block the node process." I'm saying that's not true.
A function might use threads behind the scenes, but if you're going to synchronously wait for it, you're blocking the event loop.
Re:Better-sqlite3: A faster Sqlite library for Node.js
by zbjornson on Monday March 19, 2018 @12:36PM
(#16619798)
The OP and I are talking about the C API, not the node.js API, being sync.
Re:Better-sqlite3: A faster Sqlite library for Node.js
by always_good on Tuesday March 27, 2018 @02:23PM
(#16691335)
No you weren't. Look at your first comment. You're literally relating sync in the C API with Node's API.
Re:Better-sqlite3: A faster Sqlite library for Node.js
by zbjornson on Wednesday March 28, 2018 @03:51PM
(#16701252)
My first post was talking about the C API. A sync C API can be made into an async node.js API using the thread pool. That's what node does internally for DNS resolution, fs and other APIs.
What that article is saying is that libuv exposes a thread pool that you can opt in to with a native extension instead of bringing your own.
It doesn't mean a synchronous API won't block.