Timers - Xwindows

This is a discussion on Timers - Xwindows ; Hopefully this is a simple question. Is setitimer() the correct way to implement timers in X? My first attempt at timers worked most of the time. Before I entered into select(), I would find the timer that was nearest to ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Timers

  1. Timers

    Hopefully this is a simple question. Is setitimer() the correct way to
    implement timers in X? My first attempt at timers worked most of the time.
    Before I entered into select(), I would find the timer that was nearest to
    expiration and set the select() timeout to that value. All expired timers
    would be handled and removed, all remaining timers would have their time
    remaining decremented by the last timeout amount, X events, if any, would
    be processed, and the loop would continue.

    However, sometimes my timer timeouts didn't occur exactly in sync with the
    select() timeout, so some would be left in permenant limbo. Also timers
    started within code after all existing timers expired would not be
    processed since the timout on the select() call would be null (infinite).

    I noticed that the Qt docs briefly mention timer resolutions of ~20ms, which
    is in the ballpark of the timer resolution mentioned in setitimer. That
    Since setitimer() deals with asyncronous timer events, it seems to be the
    ideal way to interrupt an infinitely blocking select() call. Is this a
    standard/typical approach to implementing timers?


  2. Re: Timers

    I have confirmed for myself that setitimer() is indeed the way to accomplish
    asyncronous timers under X.


+ Reply to Thread