Sha256: ea76cc8bcea3ef2b27ad3b29adadff8033caeb655f45b6539d602b5a69544e9e
Contents?: true
Size: 782 Bytes
Versions: 1
Compression:
Stored size: 782 Bytes
Contents
require 'revdispatch' # define this part in ruby to make sure other # ruby threads can execute while we waiting for a response module Evdispatch class Loop def response(id, timeout = 1.0, max_attempts = 100) attempts = 0 ms = timeout * 1000 # convert to miliseconds ms_i = ms.to_i seconds = ms_i / 1000 mseconds = (ms - (seconds*1000)).to_i #puts "Waiting #{seconds} seconds and #{mseconds} miliseconds" while (wait_for_response( id, seconds, mseconds ) and attempts < max_attempts ) res = response_for( id ) break if res attempts += 1 #puts "Attempt: #{attempts}" end return nil if !res and attempts == max_attempts res = response_for( id ) unless res res end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
evdispatch-0.2.2 | lib/evdispatch/loop.rb |