|
This post originated from an RSS feed registered with Ruby Buzz
by Philippe Hanrigou.
|
Original Post: SystemTimer 1.2 Release
Feed Title: Latest updates from PH7
Feed URL: http://ph7spot.com/updates/atom
Feed Description: Tips and resources on Ruby, Java, Unix, Object-Oriented Programming, Design Patterns and Agile methodologies.
|
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Philippe Hanrigou
Latest Posts From Latest updates from PH7
|
|
I have just published SystemTimer 1.2 release on Gemcutter. This new version provides support for custom timeout exceptions, will let you specify sub-second timeouts and plays nicer with Ruby interpreters compiled with -disable-pthreads.
Install SystemTimer latest version with:
sudo gem install SystemTimer
This version adds support for custom timeout exceptions. This is useful when you want to avoid interference with other libraries already using/catching Timeout::Error (e.g. Net::HTTP)
require 'system_timer'
begin
SystemTimer.timeout_after(5, MyCustomTimeoutException) do
end
rescue MyCustomTimeoutException => e
end
This patch was kindly contributed by runix
SystemTimer is going through too many layers to be able to reliably guarantee a sub-second timeout on all platforms, so – in the original SystemTimer implementation – the timeout had to be expressed as a number of seconds.
You can now specify timeouts as a fraction of a second and SystemTimer will do its best to reduce the timeout accordingly. e.g.
SystemTimer.timeout_after(0.5) do
end
Note that for stability reasons SystemTimer will not allow you to go below 200ms, e.g.
SystemTimer.timeout_after(0.01) do
end
This feature is based on an idea and original contribution by Dmytro Shteflyuk (of Scribd fame).
Changed SystemTimer implementation from using Mutex to Monitor. Mutex causes thread join errors when Ruby is compiled with -disable-pthreads.
Thanks again to Dmytro Shteflyuk who contributed this patch.
Read: SystemTimer 1.2 Release