public class SemaphoreCompletionService<T> extends Object implements CompletionService<T>
maxConcurrentTasks
tasks running at the same time.Constructor and Description |
---|
SemaphoreCompletionService(Executor executor,
int maxConcurrentTasks) |
Modifier and Type | Method and Description |
---|---|
Future<T> |
backgroundTaskFinished(Callable<T> cleanupTask)
Signal that a task that called
continueTaskInBackground() has finished and
optionally execute another task on the just-freed thread. |
void |
cancelQueuedTasks()
When stopping, cancel any queued tasks.
|
void |
continueTaskInBackground()
Called from a task to remove the permit that would otherwise be freed when the task finishes running
When the asynchronous part of the task finishes, it must call
backgroundTaskFinished(Callable)
to make the permit available again. |
List<? extends Future<T>> |
drainCompletionQueue() |
Future<T> |
poll() |
Future<T> |
poll(long timeout,
TimeUnit unit) |
Future<T> |
submit(Callable<T> task) |
Future<T> |
submit(Runnable task,
T result) |
Future<T> |
take() |
public SemaphoreCompletionService(Executor executor, int maxConcurrentTasks)
public void cancelQueuedTasks()
public void continueTaskInBackground()
backgroundTaskFinished(Callable)
to make the permit available again.public Future<T> backgroundTaskFinished(Callable<T> cleanupTask)
continueTaskInBackground()
has finished and
optionally execute another task on the just-freed thread.public Future<T> submit(Callable<T> task)
submit
in interface CompletionService<T>
public Future<T> submit(Runnable task, T result)
submit
in interface CompletionService<T>
public Future<T> take() throws InterruptedException
take
in interface CompletionService<T>
InterruptedException
public Future<T> poll()
poll
in interface CompletionService<T>
public Future<T> poll(long timeout, TimeUnit unit) throws InterruptedException
poll
in interface CompletionService<T>
InterruptedException
Copyright © 2023 JBoss, a division of Red Hat. All rights reserved.