public class WeightedListeningExecutorService
extends com.google.common.util.concurrent.AbstractListeningExecutorService
ListeningExecutorService
which gates execution using a ListeningMultiSemaphore
and allows resources to be assigned to submitted tasks.
NOTE: If futures for submitted jobs are cancelled while they are running, it's possible that the semaphore will be released for that cancelled job before it is finished, meaning more jobs may be scheduled than expected.
Constructor and Description |
---|
WeightedListeningExecutorService(ListeningMultiSemaphore semaphore,
ResourceAmounts defaultValues,
com.google.common.util.concurrent.ListeningExecutorService delegate) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
void |
execute(Runnable command) |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
shutdown() |
List<Runnable> |
shutdownNow() |
<T> com.google.common.util.concurrent.ListenableFuture<T> |
submit(Callable<T> task) |
<T> com.google.common.util.concurrent.ListenableFuture<T> |
submit(Callable<T> task,
ResourceAmounts amounts) |
com.google.common.util.concurrent.ListenableFuture<?> |
submit(Runnable task) |
com.google.common.util.concurrent.ListenableFuture<?> |
submit(Runnable task,
ResourceAmounts amounts) |
<T> com.google.common.util.concurrent.ListenableFuture<T> |
submit(Runnable task,
T result) |
<T> com.google.common.util.concurrent.ListenableFuture<T> |
submit(Runnable task,
T result,
ResourceAmounts amounts) |
WeightedListeningExecutorService |
withDefaultAmounts(ResourceAmounts newDefaultAmounts)
Creates a new service that has different default resource amounts.
|
newTaskFor, newTaskFor
invokeAll, invokeAll, invokeAny, invokeAny
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
invokeAll, invokeAll
invokeAny, invokeAny
public WeightedListeningExecutorService(ListeningMultiSemaphore semaphore, ResourceAmounts defaultValues, com.google.common.util.concurrent.ListeningExecutorService delegate)
public WeightedListeningExecutorService withDefaultAmounts(ResourceAmounts newDefaultAmounts)
newDefaultAmounts
- new default amountspublic com.google.common.util.concurrent.ListenableFuture<?> submit(Runnable task, ResourceAmounts amounts)
@Nonnull public com.google.common.util.concurrent.ListenableFuture<?> submit(Runnable task)
submit
in interface com.google.common.util.concurrent.ListeningExecutorService
submit
in interface ExecutorService
submit
in class com.google.common.util.concurrent.AbstractListeningExecutorService
public <T> com.google.common.util.concurrent.ListenableFuture<T> submit(Runnable task, @Nullable T result, ResourceAmounts amounts)
@Nonnull public <T> com.google.common.util.concurrent.ListenableFuture<T> submit(Runnable task, @Nullable T result)
submit
in interface com.google.common.util.concurrent.ListeningExecutorService
submit
in interface ExecutorService
submit
in class com.google.common.util.concurrent.AbstractListeningExecutorService
public <T> com.google.common.util.concurrent.ListenableFuture<T> submit(Callable<T> task, ResourceAmounts amounts)
@Nonnull public <T> com.google.common.util.concurrent.ListenableFuture<T> submit(Callable<T> task)
submit
in interface com.google.common.util.concurrent.ListeningExecutorService
submit
in interface ExecutorService
submit
in class com.google.common.util.concurrent.AbstractListeningExecutorService
public final boolean awaitTermination(long timeout, @Nonnull TimeUnit unit) throws InterruptedException
InterruptedException
public final boolean isShutdown()
public final boolean isTerminated()
public final void shutdown()