Methods
Public Instance methods
timed_wait(mutex, secs)

This is like ConditionVariable.wait(), but allows one to wait a maximum amount of time. Returns true if this condition was signaled, false if a timeout occurred.

     # File lib/phusion_passenger/utils.rb, line 381
381:         def timed_wait(mutex, secs)
382:                 if secs > 100000000
383:                         # NOTE: If one calls timeout() on FreeBSD 5 with an
384:                         # argument of more than 100000000, then MRI will become
385:                         # stuck in an infite loop, blocking all threads. It seems
386:                         # that MRI uses select() to implement sleeping.
387:                         # I think that a value of more than 100000000 overflows
388:                         # select()'s data structures, causing it to behave incorrectly.
389:                         # So we just make sure we can't sleep more than 100000000
390:                         # seconds.
391:                         secs = 100000000
392:                 end
393:                 if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
394:                         if secs > 0
395:                                 return wait(mutex, secs)
396:                         else
397:                                 return wait(mutex)
398:                         end
399:                 else
400:                         require 'timeout' unless defined?(Timeout)
401:                         if secs > 0
402:                                 Timeout.timeout(secs) do
403:                                         wait(mutex)
404:                                 end
405:                         else
406:                                 wait(mutex)
407:                         end
408:                         return true
409:                 end
410:         rescue Timeout::Error
411:                 return false
412:         end
timed_wait!(mutex, secs)

This is like ConditionVariable.wait(), but allows one to wait a maximum amount of time. Raises Timeout::Error if the timeout has elapsed.

     # File lib/phusion_passenger/utils.rb, line 416
416:         def timed_wait!(mutex, secs)
417:                 require 'timeout' unless defined?(Timeout)
418:                 if secs > 100000000
419:                         # See the corresponding note for timed_wait().
420:                         secs = 100000000
421:                 end
422:                 if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
423:                         if secs > 0
424:                                 if !wait(mutex, secs)
425:                                         raise Timeout::Error, "Timeout"
426:                                 end
427:                         else
428:                                 wait(mutex)
429:                         end
430:                 else
431:                         if secs > 0
432:                                 Timeout.timeout(secs) do
433:                                         wait(mutex)
434:                                 end
435:                         else
436:                                 wait(mutex)
437:                         end
438:                 end
439:                 return nil
440:         end