Hi,

I'm working on a small project that follows a pattern quite like the 
example set in the test-embed.c file on github: 
https://github.com/libuv/libuv/blob/v1.x/test/test-embed.c

I'm following this pattern in an attempt to get two different event loops 
to play nicely together, and it works fairly well, but I have changed the 
`uv_run` behavior to `UV_RUN_NOWAIT` in order to avoid locking up the 
second event loop when processing the libuv loop.

Initially this seems fine, but I've noticed that if I install an active 
handle in the libuv event loop, my poll thread will immediately notify my 
main thread that there's work to do. Then, my `uv_run(loop, UV_RUN_NOWAIT)` 
may or may not service the handle right away. In my particular case I'm 
using node.js' `setTimeout` as an example, and the poll thread will say 
"hey, there's work to do," then the main thread wakes up and runs the loop 
but maybe the timer isn't ready to fire yet, so the main thread doesn't 
actually do any work, then signals the semaphore for the poll thread. These 
two threads go back and forth like this immediately (spinning up a lot of 
CPU %) until finally the timer is ready to fire.

So, it seems that this poll strategy wakes up the main thread whenever 
there's an active handle. Is there a way to change the poll strategy to 
only wake up the main thread when there's actaully work to do? (I.e., wake 
up the main thread only when UV_RUN_NOWAIT will actually find work to do?)

Thanks,
Nick

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/libuv/f55b8831-f9cd-4464-ae2f-7327fd12f380n%40googlegroups.com.

Reply via email to