timeout.rb: revert r44520

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-01-07 12:21:51 +00:00
parent 82b1790df0
commit 1fa01c12df

View File

@ -26,21 +26,17 @@ module Timeout
class Error < RuntimeError class Error < RuntimeError
end end
class ExitException < ::Exception # :nodoc: class ExitException < ::Exception # :nodoc:
attr_reader :target attr_reader :thread
def self.current_target
Thread.current
end
def self.catch def self.catch
exc = new exc = new
exc.instance_variable_set(:@target, current_target) exc.instance_variable_set(:@thread, Thread.current)
exc.freeze exc.freeze
::Kernel.catch(exc) {yield exc} ::Kernel.catch(exc) {yield exc}
end end
def exception(*) def exception(*)
throw(self, caller) if self.target == self.class.current_target throw(self, caller) if self.thread == Thread.current
self self
end end
end end