Returns true if the enqueuing needs to be done for an ActiveJob
  class false otherwise.

 @param [Class] klass the class to check is decendant from ActiveJob

 @return [Boolean]
490861
def active_job_enqueue?(klass)
      klass.is_a?(Class) && defined?(ActiveJob::Enqueuing) &&
        klass.included_modules.include?(ActiveJob::Enqueuing)
    end
585912
def process(job = nil, &block)
      return unless job ||= reserve

      job.worker = self
      working_on job
      perform(job, &block)
    ensure
      done_working
    end
794747
def apply_to(klass, options = EMPTY_HASH)
      if mod.respond_to?(:new)
        klass.send(:include, mod.new(options))
      else
        klass.send(:include, mod)
      end
    end
1270959
def should_we_load(kls):
    
    # we don't load abstract classes
    if kls.__name__.endswith("AbstractCheck"):
        return False
    # and we only load checks
    if not kls.__name__.endswith("Check"):
        return False
    mro = kls.__mro__
    # and the class needs to be a child of AbstractCheck
    for m in mro:
        if m.__name__ == "AbstractCheck":
            return True
    return False
340039
private synchronized void resortInitQueue() {
    Comparator<JobInProgress> comp = new Comparator<JobInProgress>() {
      public int compare(JobInProgress o1, JobInProgress o2) {
        int res = o1.getPriority().compareTo(o2.getPriority());
        if(res == 0) {
          if(o1.getStartTime() < o2.getStartTime())
            res = -1;
          else
            res = (o1.getStartTime()==o2.getStartTime() ? 0 : 1);
        }
          
        return res;
      }
    };
    
    synchronized (jobInitQueue) {
      Collections.sort(jobInitQueue, comp);
    }
  }
79569
def active_job_action(klass, args)
      return if klass.blank?
      if (active_job_class = klass.safe_constantize)
        active_job_class.new(*args)
      end
    end
1185259
def running?
      all_running_response = self.class.all_running
      return all_running_response unless all_running_response.successful?

      response = Response.new :code => 0, :data => false

      if all_running_response.data.collect { |v| v.name }.include? @name
        response.data = true
      end

      response
    end
17667
def enqueue_in(number_of_seconds_from_now, klass, *args)
      enqueue_at(Time.now + number_of_seconds_from_now, klass, *args)
    end
1060091
def super_and_sub?(sup, sub)
      fqsup = qualify(sup)
      cls = qualify(store.get_superclass(sub), sub)
      until cls.nil?
        return true if cls == fqsup
        cls = qualify(store.get_superclass(cls), cls)
      end
      false
    end
1077374
def objects_of(klass)
      object = []
      ObjectSpace.each_object(klass) {|e| object.push(e) }
      object
    end
108443
def perform(id, method, *args)
      if id
        begin
          self.class.find(id).send(method, *args)
        rescue ActiveRecord::RecordNotFound
          # If the record was deleted after the job was created, swallow it
        end
      else
        self.class.send(method, *args)
      end
    end
107788
def ready(self, job):
        
        no_deps = len(job.depends_on) == 0
        all_complete = all(j.is_complete() for j in self.active_jobs
                if j.alias in job.depends_on)
        none_failed = not any(True for j in self.failed
                if j.alias in job.depends_on)
        queue_is_open = len(self.running) < self.MAX_CONCURRENT_JOBS
        return queue_is_open and (no_deps or (all_complete and none_failed))
541380
def busy(self):
        
        if self.handle.isexecuting():
            return True
        elif self.used_by is None:
            return False
        return not self.used_by() is None
885537
def run
      @done = false
      @manager_running = false
      reaper = nil

      while @queue.size > 0
        if @threads.size <= @max_threads
          @threads << Thread.new(@queue.pop) do |proc|
            Thread.current[:thread_state] = "running"
            @klass.new.instance_exec(proc[:params], &proc[:block])
            Thread.current[:thread_state] = "done"
          end       
        else
          unless @manager_running
            reaper = manage_threads 
            @manager_running = true
          end
          sleep 1
        end
      end   
      
      # Run manager if thread size never reached max
      reaper = manage_threads unless @manager_running

      # Waits until all threads are completed
      # Before exiting
      reaper.join
    end
670586
def algorithm_selected
      in_queue = false
      if (self.blastn_job && self.blastn_job.queue) ||
        (self.blastx_job && self.blastx_job.queue) ||
        (self.tblastn_job && self.tblastn_job.queue) ||
        (self.blastp_job && self.blastp_job.queue)
        in_queue = true
      end
      unless in_queue
        errors.add(
          :algorithm,
          " - Please select at least one algorithm to continue."
        )
      end
    end
852700
def idempotent_job_enqueue(job_name, time, config)
      registered = SidekiqScheduler::RedisManager.register_job_instance(job_name, time)

      if registered
        Sidekiq.logger.info "queueing #{config['class']} (#{job_name})"

        handle_errors { enqueue_job(config, time) }

        SidekiqScheduler::RedisManager.remove_elder_job_instances(job_name)
      else
        Sidekiq.logger.debug { "Ignoring #{job_name} job as it has been already enqueued" }
      end
    end
629109
def retrieve_connection(klass) #:nodoc:
      self.ensure_ready
      pool = self.retrieve_connection_pool(klass)
      (pool && pool.connection) or raise ActiveRecord::ConnectionNotEstablished
    end