Class BlockingTaskQueue.Builder
- java.lang.Object
-
- com.inductiveautomation.perspective.gateway.threading.BlockingTaskQueue.Builder
-
- Enclosing class:
- BlockingTaskQueue
public static class BlockingTaskQueue.Builder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BlockingTaskQueue
build()
BlockingTaskQueue.Builder
executor(java.util.concurrent.ExecutorService executor)
Provides the executor service that all user tasks will be executed on.BlockingTaskQueue.Builder
infiniteQueue()
Shortcut formaxQueueLength(int)
of zero.BlockingTaskQueue.Builder
infiniteTimeout()
Sets the timeout to zero, which disables the timeout system.BlockingTaskQueue.Builder
maxQueueLength(int queueLength)
BlockingTaskQueue.Builder
scheduler(java.util.concurrent.ScheduledExecutorService scheduler)
Sets the timeout scheduler using a scheduled executor service.BlockingTaskQueue.Builder
scheduler(org.python.netty.util.HashedWheelTimer wheel)
Sets the timeout scheduler to a wheel timer, which is more efficient than a scheduled executor service.BlockingTaskQueue.Builder
shutdownBehavior(BlockingTaskQueue.ShutdownBehavior shutdownBehavior)
Configures the shutdown behavior.BlockingTaskQueue.Builder
timeout(long timeout, java.util.concurrent.TimeUnit unit)
Sets the timeout, after which elapsed time an executing task will be cancelled, and its completion stage will be completed with aTaskTimedOutException
-
-
-
Method Detail
-
executor
public BlockingTaskQueue.Builder executor(java.util.concurrent.ExecutorService executor)
Provides the executor service that all user tasks will be executed on.
-
scheduler
public BlockingTaskQueue.Builder scheduler(java.util.concurrent.ScheduledExecutorService scheduler)
Sets the timeout scheduler using a scheduled executor service. It is recommened that you usescheduler(HashedWheelTimer)
instead.
-
scheduler
public BlockingTaskQueue.Builder scheduler(org.python.netty.util.HashedWheelTimer wheel)
Sets the timeout scheduler to a wheel timer, which is more efficient than a scheduled executor service.
-
infiniteTimeout
public BlockingTaskQueue.Builder infiniteTimeout()
Sets the timeout to zero, which disables the timeout system.
-
timeout
public BlockingTaskQueue.Builder timeout(long timeout, java.util.concurrent.TimeUnit unit)
Sets the timeout, after which elapsed time an executing task will be cancelled, and its completion stage will be completed with aTaskTimedOutException
-
infiniteQueue
public BlockingTaskQueue.Builder infiniteQueue()
Shortcut formaxQueueLength(int)
of zero.
-
maxQueueLength
public BlockingTaskQueue.Builder maxQueueLength(int queueLength)
- Parameters:
queueLength
- Maximum pending tasks allowed to be in the queue. If the queue is at this size, and an additional task is added, the oldest task in the queue will be rejected to make room for the new one. If this value is non-positive, the queue will be infinite.
-
shutdownBehavior
public BlockingTaskQueue.Builder shutdownBehavior(BlockingTaskQueue.ShutdownBehavior shutdownBehavior)
Configures the shutdown behavior. Default is CANCEL_PENDING
-
build
public BlockingTaskQueue build()
-
-