aboutsummaryrefslogtreecommitdiffstats
path: root/lib/thread.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/thread.rb')
-rw-r--r--lib/thread.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/thread.rb b/lib/thread.rb
index cb6d8c62fc..34c2a506d2 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