Class: EY::Snaplock::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/ey_snaplock/timer.rb

Class Method Summary collapse

Class Method Details

.timeout(sec) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/ey_snaplock/timer.rb', line 4

def self.timeout(sec)
  if RUBY_VERSION =~ /^1\.8/
    require 'system_timer'
    SystemTimer.timeout_after(sec) { yield }
  else
    require 'timeout'
    Timeout.timeout(sec) { yield }
  end
end