diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/timeout.rb | 21 | ||||
-rw-r--r-- | sample/timeout.rb | 42 | ||||
-rw-r--r-- | version.h | 4 |
4 files changed, 48 insertions, 23 deletions
@@ -1,3 +1,7 @@ +Fri Mar 12 06:37:13 2010 Nobuyoshi Nakada <[email protected]> + + * sample/timeout.rb: split from lib/timeout.rb. + Thu Mar 11 22:35:27 2010 Tanaka Akira <[email protected]> * time.c (time_round): new method Time#round. [ruby-dev:40595] diff --git a/lib/timeout.rb b/lib/timeout.rb index 893b5f8f58..1dccc57477 100644 --- a/lib/timeout.rb +++ b/lib/timeout.rb @@ -85,24 +85,3 @@ end # Another name for Timeout::Error, defined for backwards compatibility with # earlier versions of timeout.rb. TimeoutError = Timeout::Error - -if __FILE__ == $0 - p timeout(5) { - 45 - } - p timeout(5, TimeoutError) { - 45 - } - p timeout(nil) { - 54 - } - p timeout(0) { - 54 - } - p timeout(5) { - loop { - p 10 - sleep 1 - } - } -end diff --git a/sample/timeout.rb b/sample/timeout.rb new file mode 100644 index 0000000000..2870ddb239 --- /dev/null +++ b/sample/timeout.rb @@ -0,0 +1,42 @@ +require 'timeout' + +def progress(n = 5) + n.times {|i| print i; STDOUT.flush; sleep 1; i+= 1} + puts "never reach" +end + +p timeout(5) { + 45 +} +p timeout(5, TimeoutError) { + 45 +} +p timeout(nil) { + 54 +} +p timeout(0) { + 54 +} +begin + timeout(5) {progress} +rescue => e + puts e.message +end +begin + timeout(3) { + begin + timeout(5) {progress} + rescue => e + puts "never reach" + end + } +rescue => e + puts e.message +end +class MyTimeout < StandardError +end +begin + timeout(2, MyTimeout) {progress} +rescue MyTimeout => e + puts e.message +end @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_RELEASE_DATE "2010-03-11" +#define RUBY_RELEASE_DATE "2010-03-12" #define RUBY_PATCHLEVEL -1 #define RUBY_BRANCH_NAME "trunk" @@ -8,7 +8,7 @@ #define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_YEAR 2010 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 11 +#define RUBY_RELEASE_DAY 12 #include "ruby/version.h" |