Skip to content

Commit f0671d8

Browse files
authored
Simplify internal structure (#283)
* Remove unused comment * Improve Dispatcher * Simplify
1 parent ff52cee commit f0671d8

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/main/java/com/pivovarit/collectors/Dispatcher.java

+4-11
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,7 @@ final class Dispatcher<T> {
5050
}
5151

5252
CompletableFuture<Void> start() {
53-
if (!started) {
54-
started = true;
55-
} else {
56-
return completionSignaller;
57-
}
58-
53+
started = true;
5954
dispatcher.execute(withExceptionHandling(() -> {
6055
while (!Thread.currentThread().isInterrupted()) {
6156
Runnable task = workingQueue.take();
@@ -73,16 +68,14 @@ CompletableFuture<Void> start() {
7368
}, executor);
7469
}
7570
}));
76-
try {
77-
return completionSignaller;
78-
} finally {
79-
dispatcher.shutdown();
80-
}
71+
72+
return completionSignaller;
8173
}
8274

8375
void stop() {
8476
if (started) {
8577
workingQueue.add(POISON_PILL);
78+
dispatcher.shutdown();
8679
}
8780
}
8881

0 commit comments

Comments
 (0)