On Mon, Apr 24, 2017 at 12:54 PM, Narsilx Liao <[email protected]> wrote:
> Hi everyone,
>
> I'm new to libuv and I know that  is not thread-safe except
> uv_async_send().
>
> I'm writing a program(with linux c) that will create a thread(the loop
> thread) for uv_run(), which receives commands from a socket fd for creating
> or removing timers from the same loop.The Main thread will send commands
> through another socket fd to control timers creating/removing on the loop.
>
> I wonder that is it safe to add a new timer to a loop in a uv_poll_t
> callback which also on the same loop?

Yes, that is safe.

> in the callback should I call uv_stop() the loop first , add a new timer to
> loop and uv_run() the loop again?or It is safe to add a timer directly
> without uv_stop() and uv_run() the loop?

I assume uv_stop() means uv_poll_stop()?  Not necessary, you can
create the timer handle immediately.

-- 
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 https://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to