class HTTPClient::TimeoutScheduler::Period

Represents timeout period.

Attributes

thread[R]
time[R]

Public Class Methods

new(thread, time, ex) click to toggle source

Creates new Period.

# File lib/httpclient/timeout.rb, line 34
def initialize(thread, time, ex)
  @thread, @time, @ex = thread, time, ex
  @lock = Mutex.new
end

Public Instance Methods

cancel() click to toggle source

Cancel this Period. Mutex is needed to avoid too-late exception.

# File lib/httpclient/timeout.rb, line 49
def cancel
  @lock.synchronize do
    @thread = nil
  end
end
raise(message) click to toggle source

Raises if thread exists and alive.

# File lib/httpclient/timeout.rb, line 40
def raise(message)
  @lock.synchronize do
    if @thread and @thread.alive?
      @thread.raise(@ex, message)
    end
  end
end