From 3bbffbc7dd024179777192950ac07b9ef6ca2968 Mon Sep 17 00:00:00 2001 From: kosaki Date: Fri, 7 Dec 2012 10:36:59 +0000 Subject: Revert r38216 and r38221. Release manager mark this feature as "next minor". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/timeout.rb | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'lib/timeout.rb') diff --git a/lib/timeout.rb b/lib/timeout.rb index 127bccf924..7fd87ff40b 100644 --- a/lib/timeout.rb +++ b/lib/timeout.rb @@ -47,28 +47,26 @@ module Timeout # Note that this is both a method of module Timeout, so you can include # Timeout into your classes so they have a #timeout method, as well as # a module method, so you can call it directly as Timeout.timeout(). - def timeout(sec, klass = nil, immediate: false) #:yield: +sec+ + def timeout(sec, klass = nil) #:yield: +sec+ return yield(sec) if sec == nil or sec.zero? exception = klass || Class.new(ExitException) begin - Thread.async_interrupt_timing(exception => immediate ? :immediate : :on_blocking) do - begin - x = Thread.current - y = Thread.start { - begin - sleep sec - rescue => e - x.raise e - else - x.raise exception, "execution expired" - end - } - return yield(sec) - ensure - if y - y.kill - y.join # make sure y is dead. + begin + x = Thread.current + y = Thread.start { + begin + sleep sec + rescue => e + x.raise e + else + x.raise exception, "execution expired" end + } + return yield(sec) + ensure + if y + y.kill + y.join # make sure y is dead. end end rescue exception => e @@ -80,7 +78,7 @@ module Timeout level += 1 end raise if klass # if exception class is specified, it - # would be expected outside. + # would be expected outside. raise Error, e.message, e.backtrace end end -- cgit v1.2.3