From 1965a33b0f83cdf35005310afaa293e56b4cd02c Mon Sep 17 00:00:00 2001 From: Qingtian Wang Date: Tue, 21 May 2024 00:11:46 -0500 Subject: [PATCH] + using cached pool for admin tasks --- pom.xml | 10 ++++---- .../java/conseq4j/execute/ConseqExecutor.java | 6 ++--- src/test/resources/elf4j-test.properties | 25 ------------------- 3 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 src/test/resources/elf4j-test.properties diff --git a/pom.xml b/pom.xml index 47115f1..4a2136c 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ 4.0.0 io.github.q3769 conseq4j - 20230922.20230924.20240516 + 20230922.20230924.20240521 jar conseq4j A Java concurrent API to sequence related tasks while concurring unrelated ones @@ -186,19 +186,19 @@ org.junit.jupiter junit-jupiter-api - 5.9.3 + 5.10.2 test org.junit.jupiter junit-jupiter-params - 5.9.3 + 5.10.2 test org.junit.jupiter junit-jupiter-engine - 5.9.3 + 5.10.2 test @@ -221,7 +221,7 @@ io.github.q3769 coco4j - 10.0.0 + 10.1.0 diff --git a/src/main/java/conseq4j/execute/ConseqExecutor.java b/src/main/java/conseq4j/execute/ConseqExecutor.java index 3b23e5c..204f3e4 100644 --- a/src/main/java/conseq4j/execute/ConseqExecutor.java +++ b/src/main/java/conseq4j/execute/ConseqExecutor.java @@ -27,6 +27,7 @@ import static coco4j.Tasks.callUnchecked; import coco4j.DefensiveFuture; +import coco4j.ThreadFactories; import conseq4j.Terminable; import java.util.List; import java.util.Map; @@ -47,9 +48,8 @@ @ToString public final class ConseqExecutor implements SequentialExecutor, Terminable, AutoCloseable { private static final int DEFAULT_WORKER_CONCURRENCY = Runtime.getRuntime().availableProcessors(); - private static final int ADMIN_WORKER_CONCURRENCY = - Math.max(1, Runtime.getRuntime().availableProcessors() / 2); - private final ExecutorService adminService = Executors.newWorkStealingPool(ADMIN_WORKER_CONCURRENCY); + private final ExecutorService adminService = + Executors.newCachedThreadPool(ThreadFactories.newPlatformThreadFactory("conseq4j-admin")); private final Map> activeSequentialTasks = new ConcurrentHashMap<>(); /** * The worker thread pool facilitates the overall async execution, independent of the submitted tasks. Any thread diff --git a/src/test/resources/elf4j-test.properties b/src/test/resources/elf4j-test.properties deleted file mode 100644 index fc15df1..0000000 --- a/src/test/resources/elf4j-test.properties +++ /dev/null @@ -1,25 +0,0 @@ -# -# MIT License -# -# Copyright (c) 2021 Qingtian Wang -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -writer1=standard -writer1.pattern={json:caller-thread} \ No newline at end of file