node-addon-api
node-addon-api copied to clipboard
src: fix implementation of AsyncProgressWorker::Signal
Fix implementation of AsyncProgressWorker::Signal and AsyncProgressQueueWorker::Signal
Fixes: #1095 Fixes: #1081
@KevinEady could you add a short explanation of how using SendProgress instead of Signal resolves the problem? I think I know but not 100% sure.
@legendecas would be good if you reviewed as well since it seems like you were in the loop on the discussions of the original problem.
Hi @mhdawson ,
The AsyncProgress[Queue]Worker::Signal() method is supposed to call the OnProgress worker with nullptr for data and 0 for count. The main change is not using NonBlockingCall() but instead using SendProgress_().
I went about this PR by looking at the existing test we have:
https://github.com/nodejs/node-addon-api/blob/a8afb2d73c368a23ab9ed157b67e1cf8587d39c4/test/async_progress_worker.cc#L82-L83
Since sending nullptr with 0 data is allowed, I wrote Signal() to behave in this manner, by basically making progress.Signal() behave as progress.Send(nullptr, 0), which means using the SendProgress_() method.
Hope this clarifies!
Thanks, Kevin
@KevinEady many thanks for the explanation
Another thing @legendecas , i did not make any changes to AsyncProgressQueueWorker regarding a state member like 1f2cd71. Since the queue variety of the progress worker stores all progress updates, I don't think it is necessary to update the queue worker. Does this sound right?
Landed as edf630cc79eeef1029d3c1e7e47dcbcf2ab6d47b