Package net.sf.jstuff.core.concurrent
Class BlockingExecutorService
java.lang.Object
net.sf.jstuff.core.concurrent.BlockingExecutor
net.sf.jstuff.core.concurrent.BlockingExecutorService
- All Implemented Interfaces:
Executor,ExecutorService
ExecutorService that blocks submission of new tasks if a given maximum number of tasks are already pending.
- Author:
- Sebastian Thomschke
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classNested classes/interfaces inherited from class net.sf.jstuff.core.concurrent.BlockingExecutor
BlockingExecutor.RunnableWrapper -
Field Summary
Fields inherited from class net.sf.jstuff.core.concurrent.BlockingExecutor
limiter, maxPendingTasks, maxWaitTime, maxWaitTimeUnit, wrapped -
Constructor Summary
ConstructorsConstructorDescriptionBlockingExecutorService(ExecutorService executorService, int maxQueueSize, int maxWaitTime, TimeUnit maxWaitTimeUnit) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaquirePermits(int count) booleanawaitTermination(long timeout, TimeUnit unit) invokeAll(Collection<? extends Callable<T>> tasks) invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) <T> TinvokeAny(Collection<? extends Callable<T>> tasks) <T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) booleanbooleanvoidshutdown()Future<?><T> Future<T><T> Future<T>protected <T> Collection<Callable<T>>wrapTasks(Collection<? extends Callable<T>> tasks) Methods inherited from class net.sf.jstuff.core.concurrent.BlockingExecutor
aquirePermit, execute, toString
-
Constructor Details
-
BlockingExecutorService
public BlockingExecutorService(ExecutorService executorService, int maxQueueSize, int maxWaitTime, TimeUnit maxWaitTimeUnit) - Parameters:
maxWaitTime- max time to wait for a tasks being added to the queue
-
-
Method Details
-
aquirePermits
- Throws:
RejectedExecutionException
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService- Throws:
RejectedExecutionException
-
submit
- Specified by:
submitin interfaceExecutorService- Throws:
RejectedExecutionException
-
submit
- Specified by:
submitin interfaceExecutorService- Throws:
RejectedExecutionException
-
wrapTasks
protected <T> Collection<Callable<T>> wrapTasks(Collection<? extends Callable<T>> tasks) throws RejectedExecutionException - Throws:
RejectedExecutionException
-