class HTTPClient::TimeoutScheduler::Period
Represents timeout period.
Attributes
Public Class Methods
Source
# File lib/httpclient/timeout.rb, line 34 def initialize(thread, time, ex) @thread, @time, @ex = thread, time, ex @lock = Mutex.new end
Creates new Period
.
Public Instance Methods
Source
# File lib/httpclient/timeout.rb, line 49 def cancel @lock.synchronize do @thread = nil end end
Cancel this Period
. Mutex is needed to avoid too-late exception.
Source
# 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
Raises if thread exists and alive.