summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-07 12:08:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-07 12:08:45 +0000
commit82b1790df0107755a10f7d0bed2d9df33e2ac4e2 (patch)
tree7090a68348b24a1c215d432dd5030ac72068be4d
parented9f79df1a6f9891eba4d475f25682bf0048ed3f (diff)
timeout.rb: current_target
* lib/timeout.rb (Timeout::ExitException#target): rename attribute. * lib/timeout.rb (Timeout::ExitException.current_target): extract a method to achieve the target. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/timeout.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 441f8d4236b..672b2d719c0 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -26,17 +26,21 @@ module Timeout
class Error < RuntimeError
end
class ExitException < ::Exception # :nodoc:
- attr_reader :thread
+ attr_reader :target
+
+ def self.current_target
+ Thread.current
+ end
def self.catch
exc = new
- exc.instance_variable_set(:@thread, Thread.current)
+ exc.instance_variable_set(:@target, current_target)
exc.freeze
::Kernel.catch(exc) {yield exc}
end
def exception(*)
- throw(self, caller) if self.thread == Thread.current
+ throw(self, caller) if self.target == self.class.current_target
self
end
end