Hi,
I'm trying to understand worker_threads module and I'm wondering which one of these is a better way to about calling crypto/fs etc APIs (which use the libuv threadpool and have a Sync variant)
Taking the crypto.pbkdf2 as an example, 2 options are:
Option 1: Normally calling crypto.pbkdf2() on the main thread
Option 2: Calling crypto.pbkdf2Sync() on a worker thread, thus preserving the libuv pool for other tasks
Could anyone point me out to which one is better, and why? If better is situational, I will appreciate some examples in which one might be better than the other. Thanks!
Hi,
I'm trying to understand
worker_threadsmodule and I'm wondering which one of these is a better way to about calling crypto/fs etc APIs (which use the libuv threadpool and have a Sync variant)Taking the
crypto.pbkdf2as an example, 2 options are:Option 1: Normally calling
crypto.pbkdf2()on the main threadOption 2: Calling
crypto.pbkdf2Sync()on a worker thread, thus preserving the libuv pool for other tasksCould anyone point me out to which one is better, and why? If better is situational, I will appreciate some examples in which one might be better than the other. Thanks!