Package org.infinispan.executors
Class SemaphoreCompletionService<T>
java.lang.Object
org.infinispan.executors.SemaphoreCompletionService<T>
- All Implemented Interfaces:
CompletionService<T>
Executes tasks in the given executor, but never has more than
maxConcurrentTasks
tasks running at the same time.- Since:
- 7.2
- Author:
- Dan Berindei
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbackgroundTaskFinished
(Callable<T> cleanupTask) Signal that a task that calledcontinueTaskInBackground()
has finished and optionally execute another task on the just-freed thread.void
When stopping, cancel any queued tasks.void
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 callbackgroundTaskFinished(Callable)
to make the permit available again.poll()
take()
-
Constructor Details
-
SemaphoreCompletionService
-
-
Method Details
-
drainCompletionQueue
-
cancelQueuedTasks
public void cancelQueuedTasks()When stopping, cancel any queued tasks. -
continueTaskInBackground
public 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 callbackgroundTaskFinished(Callable)
to make the permit available again. -
backgroundTaskFinished
Signal that a task that calledcontinueTaskInBackground()
has finished and optionally execute another task on the just-freed thread. -
submit
- Specified by:
submit
in interfaceCompletionService<T>
-
submit
- Specified by:
submit
in interfaceCompletionService<T>
-
take
- Specified by:
take
in interfaceCompletionService<T>
- Throws:
InterruptedException
-
poll
- Specified by:
poll
in interfaceCompletionService<T>
-
poll
- Specified by:
poll
in interfaceCompletionService<T>
- Throws:
InterruptedException
-