Class Timer::Timer |
|
![]() |
timer handler, manage multiple Action objects, calling them when required. The timer must be ticked by whatever controls it, i.e. regular calls to tick() at whatever granularity suits your application's needs. Alternatively you can call run(), and the timer will tick itself, but this blocks so you gotta do it in a thread (remember ruby's threads block on syscalls so that can suck).
Methods |
Public Class methods |
new() |
Public Instance methods |
add(period, data=nil, &func) |
period: | how often (seconds) to run the action |
data: | optional data to pass to the action's proc |
func: | associate a block with add() to perform the action |
add an action to the timer
add_once(period, data=nil, &func) |
period: | how often (seconds) to run the action |
data: | optional data to pass to the action's proc |
func: | associate a block with add() to perform the action |
add an action to the timer which will be run just once, after period
remove(handle) |
remove action with handle handle from the timer
block(handle) |
block action with handle handle
unblock(handle) |
unblock action with handle handle
tick() |
you can call this when you know you're idle, or you can split off a thread and call the run() method to do it for you.
run(granularity=0.1) |
the timer will tick() itself. this blocks, so run it in a thread, and watch out for blocking syscalls