Proposal for the Manager class to manage an ExecutorService for all SignalServiceMessageSender instances (#482)

* Modified the Manager class to provide an ExecuterService for the SignalServiceMessageSender.

* removed unnesessary comment

* Changed the ExecutorService to a unbounded newCachedThreadPool

Co-authored-by: Cutkh <cutkh@users.noreply.github.com>
This commit is contained in:
Dom 2021-02-03 19:40:12 +01:00 committed by GitHub
parent c276055302
commit 23df85ff90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -167,6 +167,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
@ -189,6 +190,8 @@ public class Manager implements Closeable {
private final SignalServiceMessageReceiver messageReceiver;
private final ClientZkProfileOperations clientZkProfileOperations;
private final ExecutorService executor = Executors.newCachedThreadPool();
private SignalServiceMessagePipe messagePipe = null;
private SignalServiceMessagePipe unidentifiedMessagePipe = null;
@ -526,7 +529,6 @@ public class Manager implements Closeable {
}
private SignalServiceMessageSender createMessageSender() {
final ExecutorService executor = null;
return new SignalServiceMessageSender(serviceEnvironmentConfig.getSignalServiceConfiguration(),
account.getUuid(),
account.getUsername(),
@ -2533,6 +2535,8 @@ public class Manager implements Closeable {
}
void close(boolean closeAccount) throws IOException {
executor.shutdown();
if (messagePipe != null) {
messagePipe.shutdown();
messagePipe = null;