From 18e9d5521c17b5d2f9876088950f10884855a21d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 22 May 2024 16:51:06 +0200 Subject: [*] Switch to new CascadedThreadPool --- .../org/openslx/dozmod/filetransfer/AsyncHashGenerator.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'dozentenmodul') diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/AsyncHashGenerator.java b/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/AsyncHashGenerator.java index 07efc449..479e634d 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/AsyncHashGenerator.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/AsyncHashGenerator.java @@ -9,7 +9,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -21,7 +20,7 @@ import org.openslx.bwlp.thrift.iface.TInvalidTokenException; import org.openslx.dozmod.thrift.Session; import org.openslx.filetransfer.util.FileChunk; import org.openslx.thrifthelper.ThriftManager; -import org.openslx.util.GrowingThreadPoolExecutor; +import org.openslx.util.CascadedThreadPoolExecutor; import org.openslx.util.PrioThreadFactory; import org.openslx.util.Util; @@ -29,10 +28,12 @@ public class AsyncHashGenerator extends Thread { private static final Logger LOGGER = LogManager.getLogger(AsyncHashGenerator.class); - private static final ThreadPoolExecutor HASH_WORK_POOL = new GrowingThreadPoolExecutor(1, - Math.max(1, (int)Math.min(Runtime.getRuntime().availableProcessors() - 1, - Runtime.getRuntime().maxMemory() / (FileChunk.CHUNK_SIZE * 3))), - 10, TimeUnit.SECONDS, new LinkedBlockingQueue(1), + private static final ThreadPoolExecutor HASH_WORK_POOL = new CascadedThreadPoolExecutor(1, + Math.max(1, (int)Math.min( + Runtime.getRuntime().availableProcessors() - 1, + Runtime.getRuntime().maxMemory() / (FileChunk.CHUNK_SIZE * 3) + )), + 10, TimeUnit.SECONDS, 3, new PrioThreadFactory("HashGen"), new ThreadPoolExecutor.CallerRunsPolicy()); private static final ThreadLocal SHA1_DIGESTER = new ThreadLocal() { -- cgit v1.2.3-55-g7522