From 831eb93069492c82fa997287c77ca8d9f2ad8668 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 11 Mar 2010 21:37:16 +0000 Subject: [PATCH] * sample/timeout.rb: split from lib/timeout.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/timeout.rb | 21 --------------------- sample/timeout.rb | 42 ++++++++++++++++++++++++++++++++++++++++++ version.h | 4 ++-- 4 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 sample/timeout.rb diff --git a/ChangeLog b/ChangeLog index 9fee2f9cea..2df70c04b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Mar 12 06:37:13 2010 Nobuyoshi Nakada + + * sample/timeout.rb: split from lib/timeout.rb. + Thu Mar 11 22:35:27 2010 Tanaka Akira * 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 diff --git a/version.h b/version.h index 5219c1813e..bbf2965cde 100644 --- a/version.h +++ b/version.h @@ -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"