Skip to content

Package: TaskExecutor

TaskExecutor

Coverage

1: package de.fhdw.wtf.common.task;
2:
3: import java.util.Collection;
4: import java.util.concurrent.ExecutionException;
5:
6: import de.fhdw.wtf.common.task.result.TaskResult;
7:
8: public interface TaskExecutor {
9:         
10:         /**
11:          * Submits a task for execution. This task is started when resources are available.
12:          *
13:          * @param a
14:          * task that should be run
15:          */
16:         void submit(DependencyTask a);
17:         
18:         /**
19:          * Lets this task executor know about that task.
20:          *
21:          * @param newTask
22:          * newly introduced task
23:          * @see #startAllKnownTasks()
24:          */
25:         void introduce(DependencyTask newTask);
26:         
27:         /**
28:          * Starts all known dependency tasks that have no unmet dependencies.
29:          *
30:          * @throws InterruptedException
31:          * InterruptedException
32:          * @see #introduce(DependencyTask)
33:          */
34:         void startAllKnownTasks() throws InterruptedException;
35:         
36:         /**
37:          * Waits for the results of currently running tasks and returns them after completion. Blocks the calling thread
38:          * until no new task is submitted in a running task.
39:          *
40:          * @return results of execution
41:          * @throws InterruptedException
42:          * InterruptedException
43:          * @throws ExecutionException
44:          * ExecutionException
45:          */
46:         Collection<TaskResult> getResultsAndShutdown() throws InterruptedException, ExecutionException;
47:         
48: }