class RSpec::Support::Mutex

def wakeup_and_run_waiting_thread

def wakeup_and_run_waiting_thread
  begin
    t = @waiting.shift
    t.wakeup if t
  rescue ThreadError
    retry
  end
  Thread.critical = false
  begin
    t.run if t
  rescue ThreadError
    :noop
  end
end