9 |
|
/** |
10 |
|
* A service that decouples the production of new asynchronous tasks |
11 |
|
* from the consumption of the results of completed tasks. Producers |
12 |
< |
* <tt>submit</tt> tasks for execution. Consumers <tt>take</tt> |
12 |
> |
* {@code submit} tasks for execution. Consumers {@code take} |
13 |
|
* completed tasks and process their results in the order they |
14 |
< |
* complete. A <tt>CompletionService</tt> can for example be used to |
14 |
> |
* complete. A {@code CompletionService} can for example be used to |
15 |
|
* manage asynchronous I/O, in which tasks that perform reads are |
16 |
|
* submitted in one part of a program or system, and then acted upon |
17 |
|
* in a different part of the program when the reads complete, |
18 |
|
* possibly in a different order than they were requested. |
19 |
|
* |
20 |
< |
* <p>Typically, a <tt>CompletionService</tt> relies on a separate |
20 |
> |
* <p>Typically, a {@code CompletionService} relies on a separate |
21 |
|
* {@link Executor} to actually execute the tasks, in which case the |
22 |
< |
* <tt>CompletionService</tt> only manages an internal completion |
22 |
> |
* {@code CompletionService} only manages an internal completion |
23 |
|
* queue. The {@link ExecutorCompletionService} class provides an |
24 |
|
* implementation of this approach. |
25 |
|
* |
51 |
|
* @param task the task to submit |
52 |
|
* @param result the result to return upon successful completion |
53 |
|
* @return a Future representing pending completion of the task, |
54 |
< |
* and whose <tt>get()</tt> method will return the given |
54 |
> |
* and whose {@code get()} method will return the given |
55 |
|
* result value upon completion |
56 |
|
* @throws RejectedExecutionException if the task cannot be |
57 |
|
* scheduled for execution |
70 |
|
|
71 |
|
/** |
72 |
|
* Retrieves and removes the Future representing the next |
73 |
< |
* completed task or <tt>null</tt> if none are present. |
73 |
> |
* completed task or {@code null} if none are present. |
74 |
|
* |
75 |
|
* @return the Future representing the next completed task, or |
76 |
< |
* <tt>null</tt> if none are present |
76 |
> |
* {@code null} if none are present |
77 |
|
*/ |
78 |
|
Future<V> poll(); |
79 |
|
|
83 |
|
* time if none are yet present. |
84 |
|
* |
85 |
|
* @param timeout how long to wait before giving up, in units of |
86 |
< |
* <tt>unit</tt> |
87 |
< |
* @param unit a <tt>TimeUnit</tt> determining how to interpret the |
88 |
< |
* <tt>timeout</tt> parameter |
86 |
> |
* {@code unit} |
87 |
> |
* @param unit a {@code TimeUnit} determining how to interpret the |
88 |
> |
* {@code timeout} parameter |
89 |
|
* @return the Future representing the next completed task or |
90 |
< |
* <tt>null</tt> if the specified waiting time elapses |
90 |
> |
* {@code null} if the specified waiting time elapses |
91 |
|
* before one is present |
92 |
|
* @throws InterruptedException if interrupted while waiting |
93 |
|
*/ |