mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Merge pull request #6560 from alvasw/delegate_thread_pool_shutdown_to_guava
Delagate thread pool shutdown to Guava MoreExecutors
This commit is contained in:
commit
882afc1ff3
@ -178,16 +178,9 @@ public class Utilities {
|
||||
return executor;
|
||||
}
|
||||
|
||||
// TODO: Can some/all of the uses of this be replaced by guava MoreExecutors.shutdownAndAwaitTermination(..)?
|
||||
public static void shutdownAndAwaitTermination(ExecutorService executor, long timeout, TimeUnit unit) {
|
||||
executor.shutdown();
|
||||
try {
|
||||
if (!executor.awaitTermination(timeout, unit)) {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
//noinspection UnstableApiUsage
|
||||
MoreExecutors.shutdownAndAwaitTermination(executor, timeout, unit);
|
||||
}
|
||||
|
||||
public static <V> FutureCallback<V> failureCallback(Consumer<Throwable> errorHandler) {
|
||||
|
@ -110,8 +110,8 @@ public class BitcoindDaemon {
|
||||
} catch (IOException e) {
|
||||
log.error("Error closing block notification server socket", e);
|
||||
} finally {
|
||||
Utilities.shutdownAndAwaitTermination(executor, 1, TimeUnit.SECONDS);
|
||||
Utilities.shutdownAndAwaitTermination(workerPool, 5, TimeUnit.SECONDS);
|
||||
Utilities.shutdownAndAwaitTermination(executor, 2, TimeUnit.SECONDS);
|
||||
Utilities.shutdownAndAwaitTermination(workerPool, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,6 @@ public class PriceRequest {
|
||||
if (provider != null) {
|
||||
provider.shutDown();
|
||||
}
|
||||
Utilities.shutdownAndAwaitTermination(executorService, 1, TimeUnit.SECONDS);
|
||||
Utilities.shutdownAndAwaitTermination(executorService, 2, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ public class SeedNodeReportingService {
|
||||
dataReportTimer.stop();
|
||||
}
|
||||
|
||||
Utilities.shutdownAndAwaitTermination(executor, 2, TimeUnit.SECONDS);
|
||||
Utilities.shutdownAndAwaitTermination(executor, 4, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private void sendHeartBeat() {
|
||||
|
Loading…
Reference in New Issue
Block a user