|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jgroups.blocks.executor.ExecutionCompletionService<V>
public class ExecutionCompletionService<V>
A CompletionService that uses a supplied ExecutionService
to execute tasks. This class arranges that submitted tasks are,
upon completion, placed on a queue accessible using take.
The class is lightweight enough to be suitable for transient use
when processing groups of tasks.
This class must be used instead of a ExecutorCompletionService
provided from java.util.concurrent package. The
ExecutorCompletionService may not be used since it requires the use
of a non serializable RunnableFuture object. Since a ExecutionService
may only be used with serializable request objects, this class must be used
instead.
| Nested Class Summary | |
|---|---|
protected class |
ExecutionCompletionService.QueueingListener
|
| Field Summary | |
|---|---|
protected java.util.concurrent.BlockingQueue<NotifyingFuture<V>> |
completionQueue
|
protected ExecutionService |
executor
|
protected ExecutionCompletionService.QueueingListener |
listener
|
| Constructor Summary | |
|---|---|
|
ExecutionCompletionService(ExecutionService executor)
Creates an ExecutorCompletionService using the supplied executor for base task execution and a LinkedBlockingQueue as a completion queue. |
|
ExecutionCompletionService(ExecutionService executor,
java.util.concurrent.BlockingQueue<NotifyingFuture<V>> completionQueue)
Creates an ExecutorCompletionService using the supplied executor for base task execution and the supplied queue as its completion queue. |
protected |
ExecutionCompletionService(ExecutionService executor,
java.util.concurrent.BlockingQueue<NotifyingFuture<V>> completionQueue,
ExecutionCompletionService.QueueingListener listener)
This constructor is here if someone wants to override this class and provide their own QueueingListener to possibly listen in on futures being finished |
| Method Summary | |
|---|---|
NotifyingFuture<V> |
poll()
|
NotifyingFuture<V> |
poll(long timeout,
java.util.concurrent.TimeUnit unit)
|
java.util.concurrent.Future<V> |
submit(java.util.concurrent.Callable<V> task)
|
java.util.concurrent.Future<V> |
submit(java.lang.Runnable task,
V result)
|
NotifyingFuture<V> |
take()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final ExecutionService executor
protected final java.util.concurrent.BlockingQueue<NotifyingFuture<V>> completionQueue
protected final ExecutionCompletionService.QueueingListener listener
| Constructor Detail |
|---|
public ExecutionCompletionService(ExecutionService executor)
LinkedBlockingQueue as a completion queue.
executor - the executor to use
java.lang.NullPointerException - if executor is null
public ExecutionCompletionService(ExecutionService executor,
java.util.concurrent.BlockingQueue<NotifyingFuture<V>> completionQueue)
executor - the executor to usecompletionQueue - the queue to use as the completion queue
normally one dedicated for use by this service
java.lang.NullPointerException - if executor is null
protected ExecutionCompletionService(ExecutionService executor,
java.util.concurrent.BlockingQueue<NotifyingFuture<V>> completionQueue,
ExecutionCompletionService.QueueingListener listener)
executor - the executor to usecompletionQueue - the queue to use as the completion queue
normally one dedicated for use by this servicelistener - the listener to notify. To work properly this listner
should at minimum call the super.futureDone or else this
completion service may not work correctly.
java.lang.NullPointerException - if executor is null| Method Detail |
|---|
public java.util.concurrent.Future<V> submit(java.util.concurrent.Callable<V> task)
This future object may not be used as a NotifyingFuture. That is because internally this class sets the listener to provide ability to add to the queue.
submit in interface java.util.concurrent.CompletionService<V>
public java.util.concurrent.Future<V> submit(java.lang.Runnable task,
V result)
This future object may not be used as a NotifyingFuture. That is because internally this class sets the listener to provide ability to add to the queue.
submit in interface java.util.concurrent.CompletionService<V>
public NotifyingFuture<V> take()
throws java.lang.InterruptedException
This future may safely be used as a NotifyingFuture if desired. This is because if it tries to set a listener it will be called immediately since the task has already been completed.
take in interface java.util.concurrent.CompletionService<V>java.lang.InterruptedExceptionpublic NotifyingFuture<V> poll()
This future may safely be used as a NotifyingFuture if desired. This is because if it tries to set a listener it will be called immediately since the task has already been completed.
poll in interface java.util.concurrent.CompletionService<V>
public NotifyingFuture<V> poll(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
This future may safely be used as a NotifyingFuture if desired. This is because if it tries to set a listener it will be called immediately since the task has already been completed.
poll in interface java.util.concurrent.CompletionService<V>java.lang.InterruptedException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||