Class: Timeout::Request
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/timeout.rb |
Class Method Summary
Instance Attribute Summary
- #deadline readonly
-
#done? ⇒ Boolean
readonly
Only called by the timeout thread, so does not need Sync.synchronize
Instance Method Summary
- #expired?(now) ⇒ Boolean
- #finished
-
#interrupt
Only called by the timeout thread, so does not need Sync.synchronize
Constructor Details
.new(thread, timeout, exception_class, message) ⇒ Request
Instance Attribute Details
#deadline (readonly)
[ GitHub ]# File 'lib/timeout.rb', line 144
attr_reader :deadline
#done? ⇒ Boolean (readonly)
Only called by the timeout thread, so does not need Sync.synchronize
# File 'lib/timeout.rb', line 157
def done? @mutex.synchronize do @done end end
Instance Method Details
#expired?(now) ⇒ Boolean
# File 'lib/timeout.rb', line 163
def expired?(now) now >= @deadline end
#finished
[ GitHub ]# File 'lib/timeout.rb', line 177
def finished Sync.synchronize @mutex do @done = true end end
#interrupt
Only called by the timeout thread, so does not need Sync.synchronize
# File 'lib/timeout.rb', line 168
def interrupt @mutex.synchronize do unless @done @thread.raise @exception_class, @message @done = true end end end