Add functionality to AsyncProgressWorker::Execute to schedule future call to itself
I have a very particular usecase which goes as follows,
I have a node app running HTTP server and has a C++ bindings for some video related work. The resources served by the server hook to NAN APIs of C++ code which start infinitely long running tasks. e.g. NAN API to startProcessing will read video from an RTP source and process it until stopped. This uses gstreamer and its running on a thread outside node threadpool.
I also have requirement to know status update on this operation and so pass a JS callback to the API startProcessing(onStatusUpdateCb).
I am making use of AsyncProgressWorker at the moment to achieve this long running and multiple async callback relation between C++ and JS. I queue the worker using AsyncQueueWorker() which runs Execute on one of the available worker threads (correct me if I am wrong).
my Execute function keeps monitoring a global queue for any status updates from my gstreamer thread in a while(1) loop and calls Send when the queue is not empty.
This makes one worker thread always blocked in a while (1) loop. Is there any better way to implement my requirements? or else it would be very handy to have an API in AsyncProgressWorker to schedule future calls to Execute with a timeout. This will remove the need for while(1) loop and will also relinquish the worker thread permanently held for monitoring.
Feel free to point out any obvious mistakes in the design.
Regards, Ameya
hi @kkoopa. Can you please suggest any alternatives to above problems?
There ought to be a better way to implement said requirements, but I do not really know how. My initial guess would be using libuv directly to devise something which requires less busy waiting.
Perhaps the gstreamer thread could call uv_async_send to notify an event loop that there is something to process in the queue.