Class: Rpush::Daemon::InterruptibleSleep

Inherits:
Object
  • Object
show all
Defined in:
lib/rpush/daemon/interruptible_sleep.rb

Instance Method Summary collapse

Instance Method Details

#sleep(duration) ⇒ Object



6
7
8
9
10
# File 'lib/rpush/daemon/interruptible_sleep.rb', line 6

def sleep(duration)
  @thread = Thread.new { Kernel.sleep duration }
  Thread.pass
  @thread.join
end

#stopObject



12
13
14
15
# File 'lib/rpush/daemon/interruptible_sleep.rb', line 12

def stop
  @thread.kill if @thread
rescue StandardError # rubocop:disable Lint/HandleExceptions
end