[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] How to make a eventloop similiar to select() with a timeout of 1sec



Hi,

I am trying to convert a select() based program into using libevent, but i am having trouble to construct a way to do exactly like

select() with a timeout of 1 second.

basically I want to wait for as long as 1 second of possible events and move on to do other stuff in while(1) loop.Â

I tried :

    event_base_loopexit(g_event_base, &timeout);
    event_base_loop(g_event_base, EVLOOP_ONCE);


But I found that after several successful event triggers, the loop became shorter and shorter, Eg. after one event succesffuly triggered, the loop actually ran only 0.5 seconds next time, next time it is roughly 0.25 seconds.The more events have triggered once, the faster the loop became.Â

Any idea what to do? And If I was doing it wrong, what is the right way?

Thanks.