Usage of AsyncWorker in native nodejs module for callbacks
Documentation:
https://github.com/nodejs/nan/blob/master/doc/asyncworker.md#api_nan_async_queue_worker
Example from nodejs tests:
https://github.com/mkrufky/nan/blob/master/test/js/asyncprogressqueueworker-test.js
https://github.com/mkrufky/nan/blob/master/test/cpp/asyncprogressqueueworker.cpp
There is a test code for asyncworkers variants in napi too:
https://github.com/nodejs/node-addon-api/blob/master/test/asyncworker-persistent.cc
NAPI thread safe function looks like a more customizable way to implement callbacks. Asyncworkers have some functionality already implemented. Like keeping a reference to callback and deleting it after worker is done.
https://github.com/nodejs/node-addon-api/blob/master/doc/threadsafe_function.md
https://github.com/nodejs/node-addon-api/tree/master/test/threadsafe_function (edited)