TkRTTimer class

H

Hidetoshi NAGAI

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,459
Latest member
Vida00R129

Latest Threads

Top