summaryrefslogtreecommitdiff
path: root/lib/thread.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/thread.rb')
-rw-r--r--lib/thread.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/thread.rb b/lib/thread.rb
index 3baa951522..8b27356c48 100644
--- a/lib/thread.rb
+++ b/lib/thread.rb
@@ -189,11 +189,14 @@ class ConditionVariable
# Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup.
#
def wait(mutex)
- mutex.exclusive_unlock do
- @waiters.push(Thread.current)
- Thread.stop
+ begin
+ mutex.exclusive_unlock do
+ @waiters.push(Thread.current)
+ Thread.stop
+ end
+ ensure
+ mutex.lock
end
- mutex.lock
end
#