Class BalancedPrioritisedThreadPool
java.lang.Object
ca.spottedleaf.concurrentutil.executor.thread.BalancedPrioritisedThreadPool
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longstatic final longWhether to order tasks by (lower) stream id after (higher) priority -
Constructor Summary
ConstructorsConstructorDescriptionBalancedPrioritisedThreadPool(long groupTimeSliceNS, ThreadFactory threadFactory) BalancedPrioritisedThreadPool(long groupTimeSliceNS, ThreadFactory threadFactory, long flags) -
Method Summary
Modifier and TypeMethodDescriptionvoidadjustThreadCount(int threads) createOrderedStreamGroup(AtomicLong subOrderGenerate) Thread[]Thread[]voidhalt(boolean shutdownQueues) Prevents creation of new queues, shutdowns all non-shutdown queues if specifiedbooleanjoin(long msToWait) Waits until all threads in this pool have shutdown, or until the specified time has passed.booleanjoinInterruptable(long msToWait) Waits until all threads in this pool have shutdown, or until the specified time has passed.voidshutdown(boolean wait) Shuts down this thread pool, optionally waiting for all tasks to be executed.
-
Field Details
-
DEFAULT_GROUP_TIME_SLICE
public static final long DEFAULT_GROUP_TIME_SLICE- See Also:
-
FLAG_ORDER_BY_STREAM
public static final long FLAG_ORDER_BY_STREAMWhether to order tasks by (lower) stream id after (higher) priority- See Also:
-
DEFAULT_FLAGS
public static final long DEFAULT_FLAGS- See Also:
-
-
Constructor Details
-
BalancedPrioritisedThreadPool
-
BalancedPrioritisedThreadPool
public BalancedPrioritisedThreadPool(long groupTimeSliceNS, ThreadFactory threadFactory, long flags)
-
-
Method Details
-
getAliveThreads
-
getCoreThreads
-
halt
public void halt(boolean shutdownQueues) Prevents creation of new queues, shutdowns all non-shutdown queues if specified -
join
public boolean join(long msToWait) Waits until all threads in this pool have shutdown, or until the specified time has passed.- Parameters:
msToWait- Maximum time to wait.- Returns:
falseif the maximum time passed,trueotherwise.
-
joinInterruptable
Waits until all threads in this pool have shutdown, or until the specified time has passed.- Parameters:
msToWait- Maximum time to wait.- Returns:
falseif the maximum time passed,trueotherwise.- Throws:
InterruptedException- If this thread is interrupted.
-
shutdown
public void shutdown(boolean wait) Shuts down this thread pool, optionally waiting for all tasks to be executed. This function will invokePrioritisedExecutor.shutdown()on all created executors on this thread pool.- Parameters:
wait- Whether to wait for tasks to be executed
-
adjustThreadCount
public void adjustThreadCount(int threads) -
createOrderedStreamGroup
-
createOrderedStreamGroup
public BalancedPrioritisedThreadPool.OrderedStreamGroup createOrderedStreamGroup(AtomicLong subOrderGenerate)
-