TkRTTimer class

Hi,

I added new TkRTTimer class to Ruby/Tk.
TkRTTimer class is a little more suitable for realtime operations
than TkTimer class.
You can find that on both of CVS 1.8 and CVS Head.

A sample script of TkRTTimer is ext/tk/sample/tkrttimer.rb.
The sample shows two clocks by using TkRTTimer object and
TkTimer object. Those clocks are updated by 10 ms.
The clock with TkTimer is delayed. However, the clock with
TkRTTimer seems not to be delayed.

# except that draw processes cannot be finished in 10 ms.

TkRTTimer uses the following implement.
Now,

Ts : the time when the callback should be called
Tc : the time when the callback is called
Te : the time when the operation of the callback is finished
Tn : the next time when the callback shoule be called
       ( == Ts + requested interval )

then, the interval for the next callback is

  Tn - Te + [average of last 5 times of (Ts - Tc)]

If it is a negative value, the interval is 0 ms.

So, that is not REAL realtime operation.
However, if you want keep a fixed interval to repeat a callback
operation, I think TkRTTimer is more useful than TkTimer.
Please try it.

···

--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)