mirror of
https://github.com/bisq-network/bisq.git
synced 2025-01-19 05:44:05 +01:00
Merge pull request #6569 from alvasw/pass_connection_uid_to_executor_service_name
Connection: Pass uid to executor service name
This commit is contained in:
commit
0bdebb59e8
@ -47,7 +47,6 @@ import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
@ -134,7 +133,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
||||
private final NetworkFilter networkFilter;
|
||||
@Getter
|
||||
private final String uid;
|
||||
private final ExecutorService singleThreadExecutor = SingleThreadExecutorUtils.getSingleThreadExecutor(runnable -> new Thread(runnable, "Connection.java executor-service"));
|
||||
private final ExecutorService executorService;
|
||||
@Getter
|
||||
private final Statistic statistic;
|
||||
@Getter
|
||||
@ -180,7 +179,10 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
||||
this.socket = socket;
|
||||
this.connectionListener = connectionListener;
|
||||
this.networkFilter = networkFilter;
|
||||
uid = UUID.randomUUID().toString();
|
||||
|
||||
this.uid = UUID.randomUUID().toString();
|
||||
this.executorService = SingleThreadExecutorUtils.getSingleThreadExecutor("Executor service for connection with uid " + uid);
|
||||
|
||||
statistic = new Statistic();
|
||||
|
||||
addMessageListener(messageListener);
|
||||
@ -202,7 +204,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
||||
protoOutputStream = new ProtoOutputStream(socket.getOutputStream(), statistic);
|
||||
protoInputStream = socket.getInputStream();
|
||||
// We create a thread for handling inputStream data
|
||||
singleThreadExecutor.submit(this);
|
||||
executorService.submit(this);
|
||||
|
||||
if (peersNodeAddress != null) {
|
||||
setPeersNodeAddress(peersNodeAddress);
|
||||
@ -537,7 +539,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Utilities.shutdownAndAwaitTermination(singleThreadExecutor, SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||
Utilities.shutdownAndAwaitTermination(executorService, SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||
|
||||
log.debug("Connection shutdown complete {}", this);
|
||||
// Use UserThread.execute as it's not clear if that is called from a non-UserThread
|
||||
|
Loading…
Reference in New Issue
Block a user