Class used to manage timeout handlers across multiple threads.
Timeout handlers should be managed by using the class methods which are synchronized.
id = TimeoutHandler.register(10, Timeout::Error)
begin
  sleep 20
  puts 'foo'
ensure
  TimeoutHandler.cancel(id)
endwill raise Timeout::Error
id = TimeoutHandler.register(10, Timeout::Error)
begin
  sleep 5
  puts 'foo'
ensure
  TimeoutHandler.cancel(id)
endwill print 'foo'
Methods
    
  
  
    
    Included Modules
    
  
  
    
    
    
      
      Constants
      | TimeoutMutex | = | Mutex.new # :nodoc: | 
| Mutex used to synchronize access across threads | ||
Class Public methods
      
        
            
              cancel(id)
            
            Link
          
          
          
            Cancels the timeout handler id
            
              new()
            
            Link
          
          
          
            # File ../ruby/lib/webrick/utils.rb, line 173 def initialize @timeout_info = Hash.new Thread.start{ while true now = Time.now @timeout_info.each{|thread, ary| ary.dup.each{|info| time, exception = *info interrupt(thread, info.object_id, exception) if time < now } } sleep 0.5 end } end
            
              register(seconds, exception)
            
            Link
          
          
          
            Registers a new timeout handler
Instance Public methods
      
        
            
              cancel(thread, id)
            
            Link
          
          
          
            Cancels the timeout handler id
            
              interrupt(thread, id, exception)
            
            Link
          
          
          
            Interrupts the timeout handler id and raises
exception
            
              register(thread, time, exception)
            
            Link
          
          
          
            Registers a new timeout handler