Class QueuedTasksProcessor<T>
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.QueuedTasksProcessor<T>
-
- Type Parameters:
T
-
public class QueuedTasksProcessor<T> extends Object
This class can be used to process data in some queue asynchronously without occupying many threads. Processing is always performed in a single thread which is allocated from the executor specified in constructor.- Since:
- 2018.2.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
QueuedTasksProcessor.ManyTasksProcessor<T>
static interface
QueuedTasksProcessor.SingleTaskProcessor<T>
-
Constructor Summary
Constructors Constructor Description QueuedTasksProcessor(QueuedTasksProcessor.ManyTasksProcessor<T> tasksProcessor, ExecutorService executor, int queueSize, int maxTasksToHandle, String name)
QueuedTasksProcessor(QueuedTasksProcessor.ManyTasksProcessor<T> tasksProcessor, ExecutorService executor, BlockingQueue<T> queue, int maxTasksToHandle, String name)
QueuedTasksProcessor(QueuedTasksProcessor.SingleTaskProcessor<T> tasksProcessor, ExecutorService executor, int queueSize, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToQueue(T data)
Adds data to the queue.void
clearQueue()
List<T>
getQueuedTasks()
boolean
isQueueEmpty()
boolean
isQueueFull()
void
waitForEmptyQueue()
-
-
-
Constructor Detail
-
QueuedTasksProcessor
public QueuedTasksProcessor(@NotNull QueuedTasksProcessor.SingleTaskProcessor<T> tasksProcessor, @NotNull ExecutorService executor, int queueSize, @NotNull String name)
-
QueuedTasksProcessor
public QueuedTasksProcessor(@NotNull QueuedTasksProcessor.ManyTasksProcessor<T> tasksProcessor, @NotNull ExecutorService executor, int queueSize, int maxTasksToHandle, @NotNull String name)
- Parameters:
tasksProcessor
- processor which can handle several tasks at onceexecutor
-queueSize
-maxTasksToHandle
- max tasks to take from the queue and pass to processor at oncename
-
-
QueuedTasksProcessor
public QueuedTasksProcessor(@NotNull QueuedTasksProcessor.ManyTasksProcessor<T> tasksProcessor, @NotNull ExecutorService executor, @NotNull BlockingQueue<T> queue, int maxTasksToHandle, @NotNull String name)
- Parameters:
tasksProcessor
- processor which can handle several tasks at onceexecutor
-queue
-maxTasksToHandle
- max tasks to take from the queue and pass to processor at oncename
-
-
-
Method Detail
-
addToQueue
public void addToQueue(@NotNull T data)
Adds data to the queue. If queue is full, this method will block until some space will be available.- Parameters:
data
-
-
isQueueEmpty
public boolean isQueueEmpty()
- Returns:
- true if queue is empty and no processing is performed
-
isQueueFull
public boolean isQueueFull()
- Returns:
- true if queue is full
-
waitForEmptyQueue
public void waitForEmptyQueue()
-
clearQueue
public void clearQueue()
-
-