123456789_123456789_123456789_123456789_123456789_

Class: Gem::Timeout::Request

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: lib/rubygems/vendor/timeout/lib/timeout.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

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

[ GitHub ]

  
# File 'lib/rubygems/vendor/timeout/lib/timeout.rb', line 57

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/rubygems/vendor/timeout/lib/timeout.rb', line 55

attr_reader :deadline

#done?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rubygems/vendor/timeout/lib/timeout.rb', line 67

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

Instance Method Details

#expired?(now) ⇒ Boolean

[ GitHub ]

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

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

#finished

[ GitHub ]

  
# File 'lib/rubygems/vendor/timeout/lib/timeout.rb', line 86

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

#interrupt

[ GitHub ]

  
# File 'lib/rubygems/vendor/timeout/lib/timeout.rb', line 77

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