Module: InterruptibleSleep

Included in:
Bipbip::Agent, Bipbip::Plugin
Defined in:
lib/interruptible_sleep.rb

Instance Method Summary collapse

Instance Method Details

#interrupt_sleepObject



9
10
11
# File 'lib/interruptible_sleep.rb', line 9

def interrupt_sleep
  @_sleep_interrupt.close if @_sleep_interrupt && !@_sleep_interrupt.closed?
end

#interruptible_sleep(seconds) ⇒ Object



2
3
4
5
6
7
# File 'lib/interruptible_sleep.rb', line 2

def interruptible_sleep(seconds)
  if seconds > 0
    @_sleep_check, @_sleep_interrupt = IO.pipe
    IO.select([@_sleep_check], nil, nil, seconds)
  end
end