Created
September 20, 2011 18:52
-
-
Save stevenh512/1229959 to your computer and use it in GitHub Desktop.
Monkey-patch Ruby 1.9.2 Thread class to try to fix issue #5342
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Monkey-patch Ruby 1.9.2 Thread class to try to fix issue #5342 | |
# | |
# http://redmine.ruby-lang.org/issues/5342 | |
require 'thread' | |
class ConditionVariable | |
def wait(mutex, timeout=nil) | |
begin | |
# TODO: mutex should not be used | |
@waiters_mutex.synchronize do | |
@waiters.push(Thread.current) | |
end | |
mutex.sleep timeout | |
ensure | |
@waiters_mutex.synchronize do | |
@waiters.delete(Thread.current) | |
end | |
end | |
self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment