From c3e13f40cfc664370f635f6be1927fabdda5f1d9 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 23 Sep 2009 14:01:07 +0000 Subject: * lib/thread.rb (ConditionVariable#wait): add timeout argument. [ruby-talk:346154] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/thread.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/thread.rb b/lib/thread.rb index cb6d8c62f..34c2a506d 100644 --- a/lib/thread.rb +++ b/lib/thread.rb @@ -59,13 +59,16 @@ class ConditionVariable # # 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 -- cgit