You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: job_array.rb
    path of file: ./repos/rufus-scheduler/lib/rufus/scheduler
    
    the code of the file until where you have to start completion: 
#
# The array rufus-scheduler uses to keep jobs in order (next to trigger
# first).
#
class Rufus::Schedule
    
  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 delete_unscheduled

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

  def to_a

    @mutex.synchronize { @array.dup }
  end

  def [](job_id)

    @mutex.synchronize { @array.find { |j| j.job_id == job_id } }
  end

  def unschedule_all

    @array.each(&:unschedule)
  end
end