/** * Private method that determines how to handoff a task that needs to be re-tried. If this returns * {@code true} then the task has been taken and handed-off, and the caller is therefore no longer * responsible for executing the task. If this returns {@code false} then it's up to the caller to * try running the task again. */ private boolean handoffRetry(ScheduledTaskImpl task, Throwable t) { // NOTE: this is a very simple initial policy that always causes // tasks to re-try "in place" unless they were interrupted, in which // case there's nothing to do but re-queue the task if (t instanceof InterruptedException) { try { backingQueue.addTask(task); return true; } catch (TaskRejectedException tre) { return false; } } return false; }
/** {@inheritDoc} */ public void scheduleTask(KernelRunnable task, Identity owner, Priority priority) { backingQueue.addTask(new ScheduledTaskImpl(task, owner, priority, System.currentTimeMillis())); }
/** {@inheritDoc} */ public void scheduleTask(KernelRunnable task, Identity owner, long startTime) { backingQueue.addTask(new ScheduledTaskImpl(task, owner, defaultPriority, startTime)); }