[PATCH] added ev_timer_remain()

Denis F. Latypoff denis at gostats.ru
Tue Jun 9 10:14:31 CEST 2009


Hello Marc,

Monday, June 8, 2009, 7:08:12 PM, you wrote:

> On Mon, Jun 08, 2009 at 06:46:05PM +0700, "Denis F. Latypoff" <denis at gostats.ru> wrote:
>>   I was need to know how many time remain before fire in the timer, so
>>   I wrote a small patch. I would like libev to have this functionality
>>   in the future releases ;)

> this functionality is atcually available in all versions of libev already,
> (temporarily) stopping the timer makes it possible to read the remaining
> time, without slippage.

Ah! Thanks for the direction. But it is not efficient, isn't it?
Similar to

    timer->repeat = 30.;
    ev_timer_again (loop, timer);

instead of

    ev_timer_stop (loop, timer);
    ev_timer_set (timer, 0., 30.);
    ev_timer_start (loop, timer);

"This is slightly more efficient then stopping/starting the timer each
time you want to modify its timeout value, as libev does not have to
completely remove and re-insert the timer from/into its internal data
structure."

-- 
Best regards,
 Denis                            mailto:denis at gostats.ru




More information about the libev mailing list