On Friday, July 25, 2014 4:33:29 AM UTC-5, Saúl Ibarra Corretgé wrote:
>
> There are multiple opinions about how that should go. I for one would
> get rid of the timer repeat functionality and leave it on the hands of
> the user so you calculate the time you want. Anyway, you can calculate
> how long your callback took to execute and use uv_timer_set_repeat to
> modify it, or just call uv_timer_start with the new timeout.
>
I wound up taking the latter option, but I discovered a problem: if I set
the timeout to 0, UV_RUN_ONCE gets stuck running my callback forever
(instead of, in my example, an async_t on the same loop that's trying to
shut the loop down). See attached program, which gets stuck busylooping
forever instead of terminating.
--
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.
#include <uv.h>
uv_timer_t timer;
void run(uv_timer_t* _unused, int status) {
uv_timer_stop(&timer);
uv_timer_start(&timer, run, 0, 0);
}
void main() {
uv_loop_t* loop = uv_default_loop();
uv_timer_init(loop, &timer);
uv_timer_start(&timer, run, 0, 0);
uv_run(loop, UV_RUN_ONCE);
}