Skip to content

Commit

Permalink
fix component
Browse files Browse the repository at this point in the history
  • Loading branch information
Baunsgaard committed Jan 8, 2025
1 parent 97f1f49 commit e795ec9
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/main/java/org/apache/sysds/runtime/util/CommonThreadPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}

Expand All @@ -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;
Expand Down Expand Up @@ -335,10 +337,9 @@ else if(name.contains("test"))
return false;
}


public static class SameThreadExecutorService implements ExecutorService {

private SameThreadExecutorService(){
private SameThreadExecutorService() {
// private constructor.
}

Expand Down Expand Up @@ -444,11 +445,11 @@ public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, Ti
throw new ExecutionException("failed", e);
}

private static class NonFuture<V> implements Future<V>{
private static class NonFuture<V> implements Future<V> {

V r;

protected NonFuture(Callable<V> c){
protected NonFuture(Callable<V> c) {
try {
r = c.call();
}
Expand All @@ -459,13 +460,12 @@ protected NonFuture(Callable<V> c){

@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
return true;
}

@Override
public boolean isCancelled() {
return false;

}

@Override
Expand Down

0 comments on commit e795ec9

Please sign in to comment.