mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Use new threads API
This commit is contained in:
parent
8d55dfb66b
commit
ed8ac5b84c
7 changed files with 40 additions and 75 deletions
|
@ -1019,7 +1019,7 @@ public class ManagerImpl implements Manager {
|
|||
if (receiveThread != null || isReceivingSynchronous) {
|
||||
return;
|
||||
}
|
||||
receiveThread = new Thread(() -> {
|
||||
receiveThread = Thread.ofPlatform().name("receive-" + threadNumber.getAndIncrement()).start(() -> {
|
||||
logger.debug("Starting receiving messages");
|
||||
context.getReceiveHelper().receiveMessagesContinuously(this::passReceivedMessageToHandlers);
|
||||
logger.debug("Finished receiving messages");
|
||||
|
@ -1033,9 +1033,6 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
}
|
||||
});
|
||||
receiveThread.setName("receive-" + threadNumber.getAndIncrement());
|
||||
|
||||
receiveThread.start();
|
||||
}
|
||||
|
||||
private void passReceivedMessageToHandlers(MessageEnvelope envelope, Throwable e) {
|
||||
|
@ -1310,7 +1307,7 @@ public class ManagerImpl implements Manager {
|
|||
if (thread != null) {
|
||||
stopReceiveThread(thread);
|
||||
}
|
||||
executor.shutdown();
|
||||
executor.close();
|
||||
|
||||
dependencies.getSignalWebSocket().disconnect();
|
||||
disposable.dispose();
|
||||
|
|
|
@ -38,7 +38,7 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||
public MessageSendLogStore(final Database database, final boolean disableMessageSendLog) {
|
||||
this.database = database;
|
||||
this.sendLogDisabled = disableMessageSendLog;
|
||||
this.cleanupThread = new Thread(() -> {
|
||||
this.cleanupThread = Thread.ofPlatform().name("msl-cleanup").daemon().start(() -> {
|
||||
try {
|
||||
final var interval = Duration.ofHours(1).toMillis();
|
||||
while (!Thread.interrupted()) {
|
||||
|
@ -55,9 +55,6 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||
logger.debug("Stopping msl cleanup thread");
|
||||
}
|
||||
});
|
||||
cleanupThread.setName("msl-cleanup");
|
||||
cleanupThread.setDaemon(true);
|
||||
cleanupThread.start();
|
||||
}
|
||||
|
||||
public static void createSql(Connection connection) throws SQLException {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue