You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 4, 2018. It is now read-only.
so, having a discussion w/ @piscisaureus , @bnoordhuis et al on #libuv, and I spelled out a use case we have in Rust:
We run our libuv loop in a special task/thread that sits apart from the rest of the tasks that affect the process lifetime.
Without getting too deep into things, we are able to know when all of the "normal" (the main task and tasks/schedulers that it spawns) have ended, and receive a signal from the runtime that we need to end the "special tasks" (we call them "weak tasks"), of which the task that libuv blocks on is one.
In order to expose the libuv loop to multiple tasks/threads throughout the process, we bind a uv_async_t immediately prior to calling uv_run on the loop ptr and distribute that to any users who want to execute closures on libuv's thread (so all uv_* operations happen safely in the libuv thread, after uv_run()).
Currently, when the runtime tells us its time to exit, we uv_close this special async handle and, in the uv_close_cb, assert against the value of uv_loop_refcount to make sure that there aren't any dangling handles, as a sanity check.
The ability to do this will go away once the refcount refactor (#347) lands.
So how can we accomplish the goal, lacking this piece of API (that was never part of the public API to begin with)?
The text was updated successfully, but these errors were encountered:
I also have a similar requirement / request for a mechanism to watch for when the loop is about to finish. We have a similar situation where our extension is loading an externally written function, usually provided with a filename and a module.export function to be called with parameters. Because of this we can't add in our own callback to know when the functions are complete, upon their completion we need to trigger various events.
Currently (in 0.6.x) we are using uv_loop_refcount(uv_default_loop()); to grab the count when we're triggered and wait for it to get back to its starting position (using tick watchers).
For our project we don't need the actual refcount, we use it simply as a mechanism to know when to trigger our external event, but something along the lines of uv_*_done() would work equally as well. We are having to stay on 0.6.x until we get a fix or workaround for this. (Darn those undocumented API's!)
I'm not sure if this is still relevant. The issue dates from before we had UV_RUN_ONCE and UV_RUN_NOWAIT. nodejs/node-v0.x-archive#6316 uses a combination of both to implement a 'beforeExit' global event, no further changes to libuv required.
so, having a discussion w/ @piscisaureus , @bnoordhuis et al on #libuv, and I spelled out a use case we have in Rust:
uv_async_t
immediately prior to callinguv_run
on the loop ptr and distribute that to any users who want to execute closures on libuv's thread (so alluv_*
operations happen safely in the libuv thread, afteruv_run()
).Currently, when the runtime tells us its time to exit, we
uv_close
this special async handle and, in theuv_close_cb
, assert against the value ofuv_loop_refcount
to make sure that there aren't any dangling handles, as a sanity check.The ability to do this will go away once the refcount refactor (#347) lands.
So how can we accomplish the goal, lacking this piece of API (that was never part of the public API to begin with)?
The text was updated successfully, but these errors were encountered: