class Rpush::Daemon::InterruptibleSleep

Public Instance Methods

sleep(duration) click to toggle source
# File lib/rpush/daemon/interruptible_sleep.rb, line 4
def sleep(duration)
  @thread = Thread.new { Kernel.sleep duration }
  Thread.pass

  begin
    @thread.join
  rescue StandardError # rubocop:disable Lint/HandleExceptions
  ensure
    @thread = nil
  end
end
stop() click to toggle source
# File lib/rpush/daemon/interruptible_sleep.rb, line 16
def stop
  @thread.kill if @thread
rescue StandardError # rubocop:disable Lint/HandleExceptions
ensure
  @thread = nil
end