class Rufus::Scheduler::JobArray


first).
The array rufus-scheduler uses to keep jobs in order (next to trigger

def [](job_id)

def [](job_id)
  @mutex.synchronize { @array.find { |j| j.job_id == job_id } }
end

def delete_unscheduled

def delete_unscheduled
  @mutex.synchronize {
    @array.delete_if { |j| j.next_time.nil? || j.unscheduled_at } }
end

def each(now, &block)

def each(now, &block)
  to_a.sort_by do |job|
    job.next_time || (now + 1)
  end.each do |job|
    nt = job.next_time
    break if ( ! nt) || (nt > now)
    block.call(job)
  end
end

def initialize

def initialize
  @mutex = Mutex.new
  @array = []
end

def push(job)

def push(job)
  @mutex.synchronize { @array << job unless @array.index(job) }
  self
end

def size

def size
  @array.size
end

def to_a

def to_a
  @mutex.synchronize { @array.dup }
end

def unschedule_all

def unschedule_all
  @array.each(&:unschedule)
end