# posixtimer v0.1 # # [email protected] # # Released under the Ruby license # 12.09.05 # # Things you can do with a posixtimer: # # timer = Posix::Timer.new # # Arm the timer for 10 seconds # # begin # timer.arm(10.0) # # ..do something # # # # rescue SignalException # # The timer times out here # # end # # # Specify which type of SIGNAL to use: # # Posix::Timer.new(“ALRM”) # default # Posix::Timer.new(“USR1”) # … # # Pass a block, and it will be called upon timeout # # a = Posix::Timer.new do # puts “hi” # raise MyCustomException # end # # a.arm(5.0) # sleep 10.0 # # => “hi” # MyCustomException is raised # # # # Caveats # # # The Posix::Timer instance uses POSIX signals to trigger # the timeouts. This may conflict with other signals you wish to # use in your application. # # Passing a block to the constructor will perform a Signal.trap on # the signal. This may override an existing Signal.trap. In a future # version I intend to rollback the previous trap context. # # Multiple timers using the same signal may conflict.