Work around for wait with timeout and count_waiters

Discussion in 'Ruby' started by Sharat Mohan, Feb 11, 2009.

  1. Sharat Mohan

    Sharat Mohan Guest

    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?
    --
    Posted via http://www.ruby-forum.com/.
    Sharat Mohan, Feb 11, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TB
    Replies:
    2
    Views:
    3,732
  2. Huey

    How to make "fork/wait" to WAIT longer?

    Huey, Mar 1, 2004, in forum: C Programming
    Replies:
    1
    Views:
    1,958
    -berlin.de
    Mar 1, 2004
  3. Piet
    Replies:
    0
    Views:
    521
  4. Network/Software Buyer
    Replies:
    0
    Views:
    413
    Network/Software Buyer
    May 23, 2010
  5. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,280
    Brian Candler
    Oct 6, 2004
Loading...

Share This Page