Class BalancedPrioritisedThreadPool
java.lang.Object
ca.spottedleaf.concurrentutil.executor.thread.BalancedPrioritisedThreadPool
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBalancedPrioritisedThreadPool(long groupTimeSliceNS, Consumer<Thread> threadModifier) -
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:
-
-
Constructor Details
-
BalancedPrioritisedThreadPool
-
-
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)
-