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

ruby-changes:13295

From: akr <ko1@a...>
Date: Wed, 23 Sep 2009 23:01:26 +0900 (JST)
Subject: [ruby-changes:13295] Ruby:r25058 (trunk): * lib/thread.rb (ConditionVariable#wait): add timeout argument.

akr	2009-09-23 23:01:07 +0900 (Wed, 23 Sep 2009)

  New Revision: 25058

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

  Log:
    * lib/thread.rb (ConditionVariable#wait): add timeout argument.
      [ruby-talk:346154]

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/lib/thread.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25057)
+++ ChangeLog	(revision 25058)
@@ -1,3 +1,8 @@
+Wed Sep 23 22:58:57 2009  Tanaka Akira  <akr@f...>
+
+	* lib/thread.rb (ConditionVariable#wait): add timeout argument.
+	  [ruby-talk:346154]
+
 Wed Sep 23 21:25:20 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/bigdecimal/lib/bigdecimal/math.rb (atan): refined.
Index: lib/thread.rb
===================================================================
--- lib/thread.rb	(revision 25057)
+++ lib/thread.rb	(revision 25058)
@@ -59,13 +59,16 @@
   #
   # Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup.
   #
-  def wait(mutex)
+  # If +timeout+ is given, this method returns after +timeout+ seconds passed,
+  # even if no other thread doesn't signal.
+  #
+  def wait(mutex, timeout=nil)
     begin
       # TODO: mutex should not be used
       @waiters_mutex.synchronize do
         @waiters.push(Thread.current)
       end
-      mutex.sleep
+      mutex.sleep timeout
     end
   end
 
Index: NEWS
===================================================================
--- NEWS	(revision 25057)
+++ NEWS	(revision 25058)
@@ -230,6 +230,10 @@
   * incompatible changes:
     * Time.parse raises ArgumentError when no date information.
 
+* thread
+  * extended method:
+    * ConditionVariable#wait takes timeout argument.
+
 * securerandom
   * new methods:
     * SecureRandom.urlsafe_base64

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

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