@Test public void schedule4() throws Exception { final Executor executor = Executors.newCachedThreadPool(); LaunchTask task0 = TaskFactory.create("task0", 1000, Collections.singletonList("task2"), executor, new TestTaskCallback() { @Override public void taskStart() { } @Override public void taskEnd() { } }); LaunchTask task1 = TaskFactory.create("task1", 1000, Collections.singletonList("task0"), executor, new TestTaskCallback() { @Override public void taskStart() { } @Override public void taskEnd() { } }); LaunchTask task2 = TaskFactory.create("task2", 1000, Collections.singletonList("task1"), executor, new TestTaskCallback() { @Override public void taskStart() { } @Override public void taskEnd() { } }); try { new TaskScheduer(Arrays.asList(task2, task1, task0)).schedule(null, 0, null); } catch (Throwable throwable) { Assert.assertTrue(throwable instanceof IllegalStateException); Assert.assertTrue(throwable.getLocalizedMessage().equals("Exists a cycle in the graph")); return; } Assert.assertTrue(false); }
public void schedule(final IErrorHandler iErrorHandler, long timeout, ITimeoutHandler iTimeoutHandler, final ITasksFinishCallback iTasksFinishCallback) { final AtomicInteger taskDoneCounter = new AtomicInteger(0); final int taskCount = mTasks.size(); for (final LaunchTask task : mTasks) { task.runOn().execute(new Worker(iErrorHandler, task, mTasks, new Worker.TaskDoneCallback() { @Override public void onTaskDone() { if (taskDoneCounter.addAndGet(1) == taskCount && iTasksFinishCallback != null) { iTasksFinishCallback.onTasksFinished(); } } })); } TaskDelayChecker.delayCheckTaskAlive(mTasks, timeout, iTimeoutHandler); }
TaskScheduer { public void schedule(final IErrorHandler iErrorHandler, long timeout, ITimeoutHandler iTimeoutHandler, final ITasksFinishCallback iTasksFinishCallback) { final AtomicInteger taskDoneCounter = new AtomicInteger(0); final int taskCount = mTasks.size(); for (final LaunchTask task : mTasks) { task.runOn().execute(new Worker(iErrorHandler, task, mTasks, new Worker.TaskDoneCallback() { @Override public void onTaskDone() { if (taskDoneCounter.addAndGet(1) == taskCount && iTasksFinishCallback != null) { iTasksFinishCallback.onTasksFinished(); } } })); } TaskDelayChecker.delayCheckTaskAlive(mTasks, timeout, iTimeoutHandler); } }
TaskScheduer { public void schedule(final IErrorHandler iErrorHandler, long timeout, ITimeoutHandler iTimeoutHandler, final ITasksFinishCallback iTasksFinishCallback) { final AtomicInteger taskDoneCounter = new AtomicInteger(0); final int taskCount = mTasks.size(); for (final LaunchTask task : mTasks) { task.runOn().execute(new Worker(iErrorHandler, task, mTasks, new Worker.TaskDoneCallback() { @Override public void onTaskDone() { if (taskDoneCounter.addAndGet(1) == taskCount && iTasksFinishCallback != null) { iTasksFinishCallback.onTasksFinished(); } } })); } TaskDelayChecker.delayCheckTaskAlive(mTasks, timeout, iTimeoutHandler); } TaskScheduer(List<LaunchTask> originTasks); }
TaskScheduer { public void schedule(final IErrorHandler iErrorHandler, long timeout, ITimeoutHandler iTimeoutHandler, final ITasksFinishCallback iTasksFinishCallback) { final AtomicInteger taskDoneCounter = new AtomicInteger(0); final int taskCount = mTasks.size(); for (final LaunchTask task : mTasks) { task.runOn().execute(new Worker(iErrorHandler, task, mTasks, new Worker.TaskDoneCallback() { @Override public void onTaskDone() { if (taskDoneCounter.addAndGet(1) == taskCount && iTasksFinishCallback != null) { iTasksFinishCallback.onTasksFinished(); } } })); } TaskDelayChecker.delayCheckTaskAlive(mTasks, timeout, iTimeoutHandler); } TaskScheduer(List<LaunchTask> originTasks); void schedule(final IErrorHandler iErrorHandler, long timeout, ITimeoutHandler iTimeoutHandler, final ITasksFinishCallback iTasksFinishCallback); }
TaskScheduer { public void schedule(final IErrorHandler iErrorHandler, long timeout, ITimeoutHandler iTimeoutHandler, final ITasksFinishCallback iTasksFinishCallback) { final AtomicInteger taskDoneCounter = new AtomicInteger(0); final int taskCount = mTasks.size(); for (final LaunchTask task : mTasks) { task.runOn().execute(new Worker(iErrorHandler, task, mTasks, new Worker.TaskDoneCallback() { @Override public void onTaskDone() { if (taskDoneCounter.addAndGet(1) == taskCount && iTasksFinishCallback != null) { iTasksFinishCallback.onTasksFinished(); } } })); } TaskDelayChecker.delayCheckTaskAlive(mTasks, timeout, iTimeoutHandler); } TaskScheduer(List<LaunchTask> originTasks); void schedule(final IErrorHandler iErrorHandler, long timeout, ITimeoutHandler iTimeoutHandler, final ITasksFinishCallback iTasksFinishCallback);  }