Class: Thread

Inherits:
Object show all
Defined in:
lib/accidentally/patches/thread.rb

Class Method Summary collapse

Class Method Details

.execute_with_timeout(timeout = 0.5) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/accidentally/patches/thread.rb', line 3

def self.execute_with_timeout(timeout = 0.5)
  r = nil
  t = Thread.new {
    r = yield 
  }
  t.join(timeout)
  r
end