123456789_123456789_123456789_123456789_123456789_

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

Instance Method Summary

Constructor Details

.new(thread, timeout, exception_class, message) ⇒ Request

[ GitHub ]

  
# File 'lib/timeout.rb', line 63

def initialize(thread, timeout, exception_class, message)
  @thread = thread
  @deadline = GET_TIME.call(Process::CLOCK_MONOTONIC) + timeout
  @exception_class = exception_class
  @message = message

  @mutex = Mutex.new
  @done = false # protected by @mutex
end

Instance Attribute Details

#deadline (readonly)

[ GitHub ]

  
# File 'lib/timeout.rb', line 61

attr_reader :deadline

#done?Boolean (readonly)

[ GitHub ]

  
# File 'lib/timeout.rb', line 73

def done?
  @mutex.synchronize do
    @done
  end
end

Instance Method Details

#expired?(now) ⇒ Boolean

[ GitHub ]

  
# File 'lib/timeout.rb', line 79

def expired?(now)
  now >= @deadline
end

#finished

[ GitHub ]

  
# File 'lib/timeout.rb', line 92

def finished
  @mutex.synchronize do
    @done = true
  end
end

#interrupt

[ GitHub ]

  
# File 'lib/timeout.rb', line 83

def interrupt
  @mutex.synchronize do
    unless @done
      @thread.raise @exception_class, @message
      @done = true
    end
  end
end