Parent

HTTPClient::TimeoutScheduler

Public Instance Methods

cancel(period) click to toggle source

Cancels the given period.

# File lib/httpclient/timeout.rb, line 79
def cancel(period)
  @pool.delete(period)
  period.cancel
end
register(thread, sec, ex) click to toggle source

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

Public Class Methods

new() click to toggle source

Creates new TimeoutScheduler.

# File lib/httpclient/timeout.rb, line 57
def initialize
  @pool = {}
  @next = nil
  @thread = start_timer_thread
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.