Exemplo n.º 1
0
 public int compare(Job l, Job r) {
   // equals first, Jobs generally don't override so this should be fast
   // And this MUST be first so we can remove a job even if its timing has changed.
   if (l.equals(r)) return 0;
   // This is for _timedJobs, which always have a JobTiming.
   // PoisonJob only goes in _readyJobs.
   long ld = l.getTiming().getStartAfter() - r.getTiming().getStartAfter();
   if (ld < 0) return -1;
   if (ld > 0) return 1;
   ld = l.getJobId() - r.getJobId();
   if (ld < 0) return -1;
   if (ld > 0) return 1;
   return l.hashCode() - r.hashCode();
 }
Exemplo n.º 2
0
 /** Blocking call to retrieve the next ready job */
 Job getNext() {
   while (_alive) {
     try {
       Job j = _readyJobs.take();
       if (j.getJobId() == POISON_ID) break;
       return j;
     } catch (InterruptedException ie) {
     }
   }
   if (_log.shouldLog(Log.WARN)) _log.warn("No longer alive, returning null");
   return null;
 }