Work around for wait with timeout and count_waiters

S

Sharat Mohan

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top