The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
SystemTimer 1.2 Release

0 replies.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a flat view of this topic  Flat View
Previous Topic   Next Topic
Threaded View: This topic has 0 replies on 1 page
Philippe Hanrigou

Posts: 32
Nickname: ph7
Registered: Nov, 2007

Philippe Hanrigou is a consultant specializing in enterprise software and agile methodologies
SystemTimer 1.2 Release Posted: Mar 8, 2010 10:53 AM
Reply to this message Reply

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

Support for Custom Timeout Exceptions

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
    # Something that should be interrupted if it 
    # takes too much time...  even if blocked on 
    # a system call!
  end
rescue MyCustomTimeoutException => e
  # Recovering strategy
end

This patch was kindly contributed by runix

Sub-second Timeouts

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 
  # timeout after 500ms
end

Note that for stability reasons SystemTimer will not allow you to go below 200ms, e.g.

SystemTimer.timeout_after(0.01) do 
  # timeout at best after (uncompressable) 200ms 
  # even if 10ms is requested
end

This feature is based on an idea and original contribution by Dmytro Shteflyuk (of Scribd fame).

Better Compatibility with -disable-pthreads

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


Topic: A Technique for Creating a Talk Previous Topic   Next Topic Topic: SimplyStored and CouchDB

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use