Skip to content

Instantly share code, notes, and snippets.

@stevenh512
Created September 20, 2011 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenh512/1229959 to your computer and use it in GitHub Desktop.
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
# 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