class SidekiqScheduler::Manager

def schedule(run_loop = false)

def schedule(run_loop = false)
  watchdog("Fatal error in sidekiq, scheduler loop died") do
    return if stopped?
    # Dispatch loop
    loop do
      break logger.debug('no scheduler queues to process') unless timestamp = find_next_timestamp
      find_scheduled_work(timestamp)
    end
    # This is the polling loop that ensures we check Redis every
    # second for work, even if there was nothing to do this time
    # around.
    after(@resolution) do
      schedule(run_loop)
    end if run_loop
  end
end