Retrieves the task with earliest dead line and removes it from queue.

@return task which has earliest dead line
198442
public Task poll() {
        Task result = taskList[activeIndex].poll();
        if (result != null) {
            if (activeIndex == 0)
                result.removeFromQueue0();
            else
                result.removeFromQueue1();
        }

        return result;
    }
39253
public T first() {
        Iterator<T> iterator = iterator();
        return (iterator.hasNext() ? iterator.next() : null);
    }
120004
public <T> T execute(Task<T> task) {
        synchronized(task) {
            task.reset();
            // add it to the tail
            taskList.add(task);

            // invoke the execution
            lock.activate();

            // wait for the completion
            try {
            	while (!task.isDone()) {
            		task.wait();
            	}
            } catch (InterruptedException e) {
                task.exception = e; // we got interrupted, so task.result will be invalid! 
            }

            if(task.exception!=null) {
                Throwable e = task.exception;
                task.exception = null;
                throw new ExecutionException(e);
            } else {
                T r = task.result;
                task.result = null;
                return r;
            }
        }
    }
1195001
protected ResultQueueEntry<FlatRow> getNext() throws IOException {
    ResultQueueEntry<FlatRow> queueEntry;
    try {
      queueEntry = resultQueue.take();
      // Should never happen
      if (queueEntry == null) {
        throw new IllegalStateException("Timed out awaiting next sync rows");
      }
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new IOException("Interrupted while waiting for next result", e);
    }

    return queueEntry;
  }
139232
public <T extends Notification> T getFromQueue() {
    int batchSize = 1;
    List<NotificationQueueDto> notificationDtos = dbClient.notificationQueueDao().selectOldest(batchSize);
    if (notificationDtos.isEmpty()) {
      return null;
    }
    dbClient.notificationQueueDao().delete(notificationDtos);

    return convertToNotification(notificationDtos);
  }
85571
public Queue<PoolSchedulable> getPreemptQueue() {
    // TODO: For now, we support only one kind of scheduling.
    // Also note that FAIR is PRIORITY with equal priorities (by default)
    ScheduleComparator sPreempt = null;
    if (preemptQueue == null) {
      ScheduleComparator sc = configManager.getPoolGroupComparator(getName());
      if (sc == ScheduleComparator.PRIORITY) {
        sPreempt = ScheduleComparator.PRIORITY_PREEMPT;
      } else {
        throw new IllegalArgumentException("Unknown/misconfigured poolgroup");
      }
      preemptQueue = createPoolQueue(sPreempt);
    }
    return preemptQueue;
  }
471043
public T remove() {
        lock.lock();

        try {
            if(queue.isEmpty())
                return null;
            El<T> el=queue.poll();
            count-=el.size;
            not_full.signalAll();
            return el.el;
        }
        finally {
            lock.unlock();
        }
    }
278774
public S getEmptySequence() {
        if (empty == null)
            synchronized (this) {
                if (empty == null)
                    empty = createBuilder().createAndDestroy();
            }
        return empty;
    }
785937
public T removeFirst() {
		if (isEmpty()) {
			return null;
		}
		T firstElement = elements[firstIndex];
		elements[firstIndex] = null;
		firstIndex = incrementIndex(firstIndex, 0);
		return firstElement;
	}
154149
public alluxio.grpc.CancelTaskCommand getCancelTaskCommand() {
    return cancelTaskCommand_ == null ? alluxio.grpc.CancelTaskCommand.getDefaultInstance() : cancelTaskCommand_;
  }
805954
public synchronized JvmTask getTask(JvmContext context)
  throws IOException {
    JVMId jvmId = context.jvmId;
    LOG.debug("JVM with ID : " + jvmId + " asked for a task");
    // save pid of task JVM sent by child
    jvmManager.setPidToJvm(jvmId, context.pid);
    if (!jvmManager.isJvmKnown(jvmId)) {
      LOG.info("Killing unknown JVM " + jvmId);
      return new JvmTask(null, true);
    }
    RunningJob rjob = runningJobs.get(jvmId.getJobId());
    if (rjob == null) { //kill the JVM since the job is dead
      LOG.info("Killing JVM " + jvmId + " since job " + jvmId.getJobId() +
               " is dead");
      jvmManager.killJvm(jvmId);
      return new JvmTask(null, true);
    }
    TaskInProgress tip = jvmManager.getTaskForJvm(jvmId);
    if (tip == null) {
      return new JvmTask(null, false);
    }

    if(taskMemoryControlGroupEnabled) {
      long limit = getMemoryLimit(tip.getJobConf(), tip.getTask().isMapTask());
      ttMemCgroup.addTask(tip.getTask().getTaskID().toString(), context.pid, limit);
    }
    
    if(taskCPUControlGroupEnabled)
      ttCPUCgroup.addTask(tip.getTask().getTaskID().toString(), context.pid);
    
    if (tasks.get(tip.getTask().getTaskID()) != null) { //is task still present
      LOG.info("JVM with ID: " + jvmId + " given task: " +
          tip.getTask().getTaskID());
      return new JvmTask(tip.getTask(), false);
    } else {
      LOG.info("Killing JVM with ID: " + jvmId + " since scheduled task: " +
          tip.getTask().getTaskID() + " is " + tip.taskStatus.getRunState());
      return new JvmTask(null, true);
    }
  }
623050
public long getStartTick()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getStartTick");
    long startTick=0;
    startTick = msgItem.getMessage().getGuaranteedValueStartTick();

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getStartTick", new Long(startTick));
    return startTick;
  }
436857
public T get() {
    Barrier2 bar = _barrier;
    if( bar != null )           // Barrier may be null if task already completed
      bar.join(); // Block on the *barrier* task, which blocks until the fjtask on*Completion code runs completely
    assert isStopped();
    if (_ex!=null)
      throw new RuntimeException((Throwable)AutoBuffer.javaSerializeReadPojo(_ex));
    // Maybe null return, if the started fjtask does not actually produce a result at this Key
    return _result==null ? null : _result.get(); 
  }
280870
public alluxio.grpc.CancelTaskCommandOrBuilder getCancelTaskCommandOrBuilder() {
    return cancelTaskCommand_ == null ? alluxio.grpc.CancelTaskCommand.getDefaultInstance() : cancelTaskCommand_;
  }
690441
public Queue<PoolGroupSchedulable> getPreemptQueue() {
    if (preemptQueue == null) {
      preemptQueue = createPoolGroupQueue(ScheduleComparator.FAIR_PREEMPT);
    }
    return preemptQueue;
  }
781107
public SiteTasker poll()
    {
        SiteTasker task = m_tasks.poll();
        if (task != null) {
            m_queueDepthTracker.pollUpdate(task.getQueueOfferTime());
        }
        return task;
    }
453042
private static Runnable nextTask() {
		synchronized (lock) {
			// Block until we have another object in the queue to execute.
			while (taskList.isEmpty()) {
				try {
					lock.wait();
				} catch (InterruptedException ie) {
				}
			}
			return (Runnable) taskList.removeLast();
		}
	}