Work around for wait with timeout and count_waiters

I was using following code in ruby 1.8

def self.wait_for_completion_on(signal_data)
  signal_data.lock.synchronize do
    if signal_data.lock.count{|i| !i.nil?} > 0
      signal_data.lock.clear
    else
      k = 0
      while k < SipperConfigurator[:WaitSecondsForTestCompletion]
        signal_data.cond.wait(3)
        break if signal_data.lock.count{|i| !i.nil?} > 0
      end
    end
  end
end


def self.signal_waiting_test(test_name, proxy_call=false)
  signal_data = SIP::Locator[:Tlocks][test_name] if

SIP::Locator[:Tlocks]
unless signal_data
return false
end
signal_data.lock.synchronize do
signal_data.lock << “signal”
if signal_data.cond.count_waiters > 0
signal_data.cond.signal
else
SipLogger[‘siplog::sip_testcompletionsignalinghelper’].debug
“Queueing the signal”
end
end
end

But now moving to 1.9, wait with timeout on cond variable and
count_waiters is not implemented in montior.rb. What should be the
workaround?