33 lines
1.1 KiB
Java
33 lines
1.1 KiB
Java
package org.warp.commonutils.concurrency.executor;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
public class AsyncStackTraceExecutorServiceDecorator extends SimplerExecutorServiceDecorator {
|
|
|
|
// todo: Fix async stacktrace performance and memory problems
|
|
private static final boolean DISABLE_ASYNC_STACKTRACES_GLOBALLY = true;
|
|
|
|
public AsyncStackTraceExecutorServiceDecorator(ExecutorService executorService) {
|
|
super(executorService, (executor) -> {
|
|
if (DISABLE_ASYNC_STACKTRACES_GLOBALLY) {
|
|
return executor;
|
|
}
|
|
|
|
// Do nothing if it has already the asyncstacktrace executor service decorator
|
|
if (executorService instanceof ExecutorServiceDecorator) {
|
|
var decorators = ((ExecutorServiceDecorator) executorService).getExecutorServiceDecorators();
|
|
if (decorators.contains(AsyncStackTraceExecutorServiceDecorator.class)) {
|
|
return new ExecutorDecorator(executorService) {
|
|
@Override
|
|
public void execute(@NotNull Runnable runnable) {
|
|
super.execute(runnable);
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
return new AsyncStackTraceExecutorDecorator(executor);
|
|
});
|
|
}
|
|
} |