Skip to content

Commit dfa2efd

Browse files
committed
+ internal clean up
1 parent 8cdbb49 commit dfa2efd

File tree

2 files changed

+7
-27
lines changed

2 files changed

+7
-27
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<modelVersion>4.0.0</modelVersion>
2828
<groupId>io.github.q3769</groupId>
2929
<artifactId>conseq4j</artifactId>
30-
<version>20231102.0.20231104</version>
30+
<version>20231102.0.20231105</version>
3131
<packaging>jar</packaging>
3232
<name>conseq4j</name>
3333
<description>A Java concurrent API to sequence related tasks while concurring unrelated ones</description>

src/main/java/conseq4j/summon/ConseqServiceFactory.java

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
import java.util.Collection;
3232
import java.util.List;
3333
import java.util.Objects;
34-
import java.util.concurrent.*;
34+
import java.util.concurrent.ConcurrentHashMap;
35+
import java.util.concurrent.ConcurrentMap;
36+
import java.util.concurrent.ExecutorService;
37+
import java.util.concurrent.Executors;
3538
import java.util.stream.Collectors;
3639
import javax.annotation.Nonnull;
3740
import javax.annotation.concurrent.ThreadSafe;
@@ -102,10 +105,8 @@ public ExecutorService getExecutorService(@NonNull Object sequenceKey) {
102105
*/
103106
@Override
104107
public void close() {
105-
Collection<ShutdownDisabledExecutorService> shutdownDisabledExecutorServices = sequentialExecutors.values();
106-
shutdownDisabledExecutorServices.forEach(ShutdownDisabledExecutorService::closeDelegate);
107-
awaitForever().until(() -> shutdownDisabledExecutorServices.stream()
108-
.allMatch(ShutdownDisabledExecutorService::isTerminated));
108+
sequentialExecutors.values().forEach(ShutdownDisabledExecutorService::shutdownDelegate);
109+
awaitForever().until(this::isTerminated);
109110
}
110111

111112
private int bucketOf(Object sequenceKey) {
@@ -169,27 +170,6 @@ public void shutdown() {
169170
throw new UnsupportedOperationException(SHUTDOWN_UNSUPPORTED_MESSAGE);
170171
}
171172

172-
void closeDelegate() {
173-
boolean terminated = isTerminated();
174-
if (!terminated) {
175-
shutdownDelegate();
176-
boolean interrupted = false;
177-
while (!terminated) {
178-
try {
179-
terminated = awaitTermination(1L, TimeUnit.DAYS);
180-
} catch (InterruptedException e) {
181-
if (!interrupted) {
182-
shutdownDelegateNow();
183-
interrupted = true;
184-
}
185-
}
186-
}
187-
if (interrupted) {
188-
Thread.currentThread().interrupt();
189-
}
190-
}
191-
}
192-
193173
void shutdownDelegate() {
194174
this.delegate.shutdown();
195175
}

0 commit comments

Comments
 (0)