9 |
|
|
10 |
|
/** |
11 |
|
* A {@link CompletionService} that uses a supplied {@link Executor} |
12 |
< |
* to execute tasks. |
12 |
> |
* to execute tasks. This class arranges that submitted tasks are, |
13 |
> |
* upon completion, placed on a queue accessible using <tt>take</tt>. |
14 |
> |
* The class is lightweight enough to be suitable for transient use |
15 |
> |
* when processing groups of tasks. |
16 |
|
* |
17 |
|
* <p> |
18 |
|
* |
103 |
|
* executor for base task execution and the supplied queue as its |
104 |
|
* completion queue. |
105 |
|
* @param executor the executor to use |
106 |
< |
* @param completionQueue the queue to use as the completion queue; |
106 |
> |
* @param completionQueue the queue to use as the completion queue |
107 |
|
* normally one dedicated for use by this service |
108 |
|
8 @throws NullPointerException if executor or completionQueue are <tt>null</tt> |
109 |
|
*/ |
116 |
|
} |
117 |
|
|
118 |
|
public Future<V> submit(Callable<V> task) { |
119 |
+ |
if (task == null) throw new NullPointerException(); |
120 |
|
QueueingFuture f = new QueueingFuture(task); |
121 |
|
executor.execute(f); |
122 |
|
return f; |
123 |
|
} |
124 |
|
|
125 |
|
public Future<V> submit(Runnable task, V result) { |
126 |
+ |
if (task == null) throw new NullPointerException(); |
127 |
|
QueueingFuture f = new QueueingFuture(task, result); |
128 |
|
executor.execute(f); |
129 |
|
return f; |