[前][次][番号順一覧][スレッド一覧]

ruby-changes:32441

From: nobu <ko1@a...>
Date: Tue, 7 Jan 2014 21:08:53 +0900 (JST)
Subject: [ruby-changes:32441] nobu:r44520 (trunk): timeout.rb: current_target

nobu	2014-01-07 21:08:45 +0900 (Tue, 07 Jan 2014)

  New Revision: 44520

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44520

  Log:
    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.

  Modified files:
    trunk/lib/timeout.rb
Index: lib/timeout.rb
===================================================================
--- lib/timeout.rb	(revision 44519)
+++ lib/timeout.rb	(revision 44520)
@@ -26,17 +26,21 @@ module Timeout https://github.com/ruby/ruby/blob/trunk/lib/timeout.rb#L26
   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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]