TT上的资源释放:
/**
* 该函数在任务被杀掉和任务结束的时候被调用(kill和reportTaskFinished ),比如在kill task时:
* 如果该任务已经占据了这个slot,首先增加free slot的总数目,通知所有等待在free slot上的线程并将slotTaken置否,
* 如果该任务忆还没有占据该slot,直接通知所有等待在free slot上的线程。
*/
private synchronized void releaseSlot() {
if (slotTaken) {
if (launcher != null) {
launcher.addFreeSlots(task.getNumSlotsRequired());
}
slotTaken = false;
} else {
// wake up the launcher. it may be waiting to block slots for
// this task.
if (launcher != null) {
launcher.notifySlots();
}
}
}