From e795ec94f8bda754a6b775dbc273c06084915313 Mon Sep 17 00:00:00 2001 From: Sebastian Baunsgaard Date: Wed, 8 Jan 2025 18:07:27 +0100 Subject: [PATCH] fix component --- .../sysds/runtime/util/CommonThreadPool.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/apache/sysds/runtime/util/CommonThreadPool.java b/src/main/java/org/apache/sysds/runtime/util/CommonThreadPool.java index eb3e46b8345..0c4854dc104 100644 --- a/src/main/java/org/apache/sysds/runtime/util/CommonThreadPool.java +++ b/src/main/java/org/apache/sysds/runtime/util/CommonThreadPool.java @@ -72,7 +72,7 @@ public class CommonThreadPool implements ExecutorService { private final ExecutorService _pool; /** Local variable indicating if there was a thread that was not main, and requested a thread pool */ - private static boolean incorrectPoolUse = false; + private static boolean incorrectPoolUse = false; /** * Constructor of the threadPool. This is intended not to be used except for tests. Please use the static @@ -104,8 +104,9 @@ public static ExecutorService get() { * @return The executor with specified parallelism */ public synchronized static ExecutorService get(int k) { - if(k <= 1){ - LOG.warn("Invalid to create thread pool with <= one thread returning single thread executor", new RuntimeException()); + if(k <= 1) { + LOG.warn("Invalid to create thread pool with <= one thread returning single thread executor", + new RuntimeException()); return new SameThreadExecutorService(); } @@ -130,9 +131,10 @@ else if(mainThread || threadName.contains("PARFOR")) { } else { // If we are neither a main thread or parfor thread, allocate a new thread pool - if(!incorrectPoolUse){ - LOG.warn("An instruction allocated it's own thread pool indicating that some task is not properly reusing the threads."); - + if(!incorrectPoolUse) { + LOG.warn( + "An instruction allocated it's own thread pool indicating that some task is not properly reusing the threads."); + if(threadName.contains("test")) LOG.error("Thread from test is not correctly using pools, please modify thread name to contain 'main'"); incorrectPoolUse = true; @@ -335,10 +337,9 @@ else if(name.contains("test")) return false; } - public static class SameThreadExecutorService implements ExecutorService { - private SameThreadExecutorService(){ + private SameThreadExecutorService() { // private constructor. } @@ -444,11 +445,11 @@ public T invokeAny(Collection> tasks, long timeout, Ti throw new ExecutionException("failed", e); } - private static class NonFuture implements Future{ + private static class NonFuture implements Future { V r; - protected NonFuture(Callable c){ + protected NonFuture(Callable c) { try { r = c.call(); } @@ -459,13 +460,12 @@ protected NonFuture(Callable c){ @Override public boolean cancel(boolean mayInterruptIfRunning) { - return false; + return true; } @Override public boolean isCancelled() { return false; - } @Override