Package org.jivesoftware.util
Class ScheduledExecutorCompletionService<V>
- java.lang.Object
-
- org.jivesoftware.util.ScheduledExecutorCompletionService<V>
-
- All Implemented Interfaces:
CompletionService<V>
public class ScheduledExecutorCompletionService<V> extends Object implements CompletionService<V>
A CompletionService that allows solvers to be scheduled. This implementation borrows a lot fromExecutorCompletionService, which sadly is not designed to be extensible.- Author:
- Guus der Kinderen, guus@goodbytes.nl
-
-
Constructor Summary
Constructors Constructor Description ScheduledExecutorCompletionService(ScheduledThreadPoolExecutor executor)Creates an ExecutorCompletionService using the supplied executor for base task execution and aLinkedBlockingQueueas a completion queue.ScheduledExecutorCompletionService(ScheduledThreadPoolExecutor executor, BlockingQueue<Future<V>> completionQueue)Creates an ExecutorCompletionService using the supplied executor for base task execution and the supplied queue as its completion queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Future<V>poll()Future<V>poll(long timeout, TimeUnit unit)Future<V>schedule(Callable<V> task, long delay, TimeUnit unit)Future<V>schedule(Callable<V> task, Duration delay)Future<V>submit(Runnable task, V result)Future<V>submit(Callable<V> task)Future<V>take()
-
-
-
Constructor Detail
-
ScheduledExecutorCompletionService
public ScheduledExecutorCompletionService(ScheduledThreadPoolExecutor executor)
Creates an ExecutorCompletionService using the supplied executor for base task execution and aLinkedBlockingQueueas a completion queue.- Parameters:
executor- the executor to use- Throws:
NullPointerException- if executor isnull
-
ScheduledExecutorCompletionService
public ScheduledExecutorCompletionService(ScheduledThreadPoolExecutor executor, BlockingQueue<Future<V>> completionQueue)
Creates an ExecutorCompletionService using the supplied executor for base task execution and the supplied queue as its completion queue.- Parameters:
executor- the executor to usecompletionQueue- the queue to use as the completion queue normally one dedicated for use by this service. This queue is treated as unbounded -- failed attemptedQueue.addoperations for completed tasks cause them not to be retrievable.- Throws:
NullPointerException- if executor or completionQueue arenull
-
-
Method Detail
-
submit
@Nonnull public Future<V> submit(@Nonnull Callable<V> task)
- Specified by:
submitin interfaceCompletionService<V>- Throws:
RejectedExecutionExceptionNullPointerException
-
submit
@Nonnull public Future<V> submit(@Nonnull Runnable task, V result)
- Specified by:
submitin interfaceCompletionService<V>- Throws:
RejectedExecutionExceptionNullPointerException
-
take
public Future<V> take() throws InterruptedException
- Specified by:
takein interfaceCompletionService<V>- Throws:
InterruptedException
-
poll
public Future<V> poll()
- Specified by:
pollin interfaceCompletionService<V>
-
poll
public Future<V> poll(long timeout, @Nonnull TimeUnit unit) throws InterruptedException
- Specified by:
pollin interfaceCompletionService<V>- Throws:
InterruptedException
-
-