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)
end

will raise Timeout::Error

id = TimeoutHandler.register(10, Timeout::Error)
begin
  sleep 5
  puts 'foo'
ensure
  TimeoutHandler.cancel(id)
end

will print ‘foo’

Constants

Mutex used to synchronize access across threads

Class Methods

Cancels the timeout handler id

Creates a new TimeoutHandler. You should use ::register and ::cancel instead of creating the timeout handler directly.

Registers a new timeout handler

time

Timeout in seconds

exception

Exception to raise when timeout elapsed

No documentation available