mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
moved shutdownNow only to the main thread
Conflicts: src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java
This commit is contained in:
@@ -56,7 +56,6 @@ abstract class AbstractChannelReplicator implements Closeable {
|
||||
|
||||
static final int SIZE_OF_SIZE = 4;
|
||||
public static final int SIZE_OF_TRANSACTION_ID = 8;
|
||||
public static final int SIZE_OF_TIME_SHIFT = 2;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractChannelReplicator.class);
|
||||
|
||||
@@ -228,7 +227,15 @@ abstract class AbstractChannelReplicator implements Closeable {
|
||||
if (Thread.interrupted())
|
||||
LOG.warn("Already interrupted");
|
||||
long start = System.currentTimeMillis();
|
||||
closeResources();
|
||||
try {
|
||||
closeResources();
|
||||
if (!executorService.awaitTermination(5, TimeUnit.MILLISECONDS)) {
|
||||
executorService.shutdownNow();
|
||||
executorService.awaitTermination(10, TimeUnit.SECONDS);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("", e);
|
||||
}
|
||||
|
||||
try {
|
||||
if (future != null)
|
||||
@@ -254,21 +261,9 @@ abstract class AbstractChannelReplicator implements Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
public void closeResources() {
|
||||
public void closeResources() throws InterruptedException {
|
||||
isClosed = true;
|
||||
executorService.shutdown();
|
||||
|
||||
try {
|
||||
executorService.awaitTermination(5, TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
executorService.shutdownNow();
|
||||
try {
|
||||
executorService.awaitTermination(10, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e1) {
|
||||
LOG.error("", e);
|
||||
}
|
||||
}
|
||||
|
||||
closeables.closeQuietly();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user