Represents timeout period.
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
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
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