On Mon, Oct 26, 2015 at 2:50 PM, Karim Benjelloun Herrera <[email protected]> wrote: > Hello everyone, I have a question that I still haven't found the solution > for it. So I would like to ask here if someone knows how to solve it. > > I am making a C++ addon for Node. And I would like to run uv_queue_work > multiple times without having to use a while/sleep the main thread. Any idea > of how to do this? > > So far I've done this: > > void main(const FunctionCallbackInfo<Value>& args) { > //here goes my main code > > //Here I schedule the worker, to run BEFOREmethod in a new thread, and > AFTERmethod in the main thread > uv_queue_work(uv_default_loop(), req, BEFOREmethod,(uv_after_work_cb) > AFTERmethod); > > return callback; > } > > > > void BEFOREmethod(uv_work_t* req){ > > //here goes the code that runs in new thread > usleep(200000); > } > > > > > void AFTERmethod(uv_work_t* req, int status){ > > //here goes the code that runs in main thread > > //Then we schedule the uv_queue_work again > uv_queue_work(uv_default_loop(), req, BEFOREmethod,(uv_after_work_cb) > AFTERmethod); > } > > So this works, I can re-schedule the uv_queue_work, but there is a memory > leak, if I keep this running, memory usage keeps increasing. But I haven't > found another way of doing this. So I would appreciate any help if anybody > has an idea. > > Thanks in advance! > > > Karim
It's hard to tell what is going on, the code you posted is obviously incomplete. `req` is not defined anywhere, for example. -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
