Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create async loops #2

adrai opened this issue Jul 22, 2013 · 2 comments


Copy link

commented Jul 22, 2013

I want to execute the NanAsyncWorker again after HandleOKCallback, to do a async loop.
For example to read from a device ;-)

How would you recommend to do that? Sorry I'm not really good in C++... :-(

PS. thanks for nan, it's cool...


This comment has been minimized.

Copy link

commented Jul 23, 2013

So, the worker is deleted as a result of uv_queue_work coming back, in the NanAsyncExecuteComplete function. What you could do is not use NanAsyncExecuteWorker() but call uv_queue_work() directly yourself to re-queue your worker and ensure it's not deleted and the callback handle disposed. It shouldn't be too hard:

But, you might want to reconsider what you're doing, perhaps you want your JS code to be triggering the re-runs rather than having the C++ side dictating when the loops occur. Another alternative is to use polling, if you dare and have some kind of socket to react to, like the zmq module does: (and I do this in node-libssh too but it's much cleaner in the zmmq one).

@rvagg rvagg closed this Jul 23, 2013

This comment has been minimized.

Copy link

commented Jul 23, 2013

agnat pushed a commit that referenced this issue May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.