private void linkOut(Task task) { Task head = slots[task.slot()]; if (task.next() == task) { slots[task.slot()] = null; } else { task.prev().next(task.next()); task.next().prev(task.prev()); if (head == task) { slots[task.slot()] = task.next(); } } task.next(null); task.prev(null); --counts[task.slot()]; }
public synchronized void schedule(Task task, double seconds) { if (task.isKilled()) { return; } if (seconds < 0.0) { throw new IllegalArgumentException("cannot schedule a Task in the past"); } int ticks = 1 + (int) (seconds * 10.0 + 0.5); if (isActive(task)) { linkOut(task); } task.slot((ticks + currSlot) & MASK); task.iter(currIter + ((ticks + currSlot) >> SHIFT)); linkIn(task); }
public synchronized void scheduleNow(Task task) { if (task.isKilled()) { return; } if (isActive(task)) { linkOut(task); } task.slot(SLOTS); task.iter(0); linkIn(task); }