Forum: Ruby Work around for wait with timeout and count_waiters

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A452856d6df66f3820909e73fffc2ec0?d=identicon&s=25 Sharat Mohan (sharat)
on 2009-02-11 17:00
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?
This topic is locked and can not be replied to.