Creates new TimeoutScheduler.
# File lib/httpclient/timeout.rb, line 57 def initialize @pool = {} @next = nil @thread = start_timer_thread end
Cancels the given period.
# File lib/httpclient/timeout.rb, line 79 def cancel(period) @pool.delete(period) period.cancel end
Registers new timeout period.
# File lib/httpclient/timeout.rb, line 64 def register(thread, sec, ex) period = Period.new(thread, Time.now + sec, ex || ::Timeout::Error) @pool[period] = true if @next.nil? or period.time < @next begin @thread.wakeup rescue ThreadError # Thread may be dead by fork. @thread = start_timer_thread end end period end
Generated with the Darkfish Rdoc Generator 2.