clintropolis commented on code in PR #18176:
URL: https://github.com/apache/druid/pull/18176#discussion_r2289081074
##########
processing/src/main/java/org/apache/druid/java/util/common/concurrent/Execs.java:
##########
@@ -173,6 +175,97 @@ public void rejectedExecution(Runnable r,
ThreadPoolExecutor executor)
);
}
+ public static ExecutorService newBlockingCached(
+ final String nameFormat,
+ int minThreads,
+ int maxThreads,
+ long keepAliveTime,
+ TimeUnit keepAliveTimeUnit,
+ final Integer priority
+ )
+ {
+ final BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
+ if (minThreads == maxThreads) {
+ return new ThreadPoolExecutor(
+ minThreads,
+ maxThreads,
+ keepAliveTime,
+ keepAliveTimeUnit,
+ queue,
+ makeThreadFactory(nameFormat, priority),
+ (r, executor) -> {
+ if (executor.isShutdown()) {
+ throw new RejectedExecutionException("Executor is shutdown,
rejecting task");
+ }
+ try {
+ executor.getQueue().put(r);
+ }
+ catch (InterruptedException e) {
+ throw new RejectedExecutionException("Got Interrupted while
adding to the Queue", e);
+ }
+ }
+ );
+ }
+ return new ThreadPoolExecutor(
+ minThreads,
+ maxThreads,
+ keepAliveTime,
+ keepAliveTimeUnit,
+ queue,
+ makeThreadFactory(nameFormat, priority),
+ (r, executor) -> {
+ if (executor.isShutdown()) {
+ throw new RejectedExecutionException("Executor is shutdown,
rejecting task");
+ }
+ try {
+ executor.getQueue().put(r);
+ }
+ catch (InterruptedException e) {
+ throw new RejectedExecutionException("Got Interrupted while adding
to the Queue", e);
+ }
+ }
+ )
+ {
+ private int running = 0;
+
+ @Override
+ public void execute(Runnable command)
+ {
+ synchronized (this) {
+ running++;
+ growIfNeeded();
Review Comment:
deleted this in favor of always using a fixed pool
re: virtual threads, I guess I was just imagining this thread pool would be
replaced with virtual threads, i'm less certain if processing threads in
general should be virtual threads since they are expected to be doing lots of
work, but it would be interesting to experiment with
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]