moved shutdownNow only to the main thread

Conflicts:
	src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java
This commit is contained in:
Rob Austin
2015-07-25 15:59:16 +03:00
committed by leventov
parent 76d6817c41
commit d8d800d614
@@ -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();
}