mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Try to close alive ChronicleMaps on JVM shutdown
This commit is contained in:
@@ -1504,14 +1504,19 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
} finally {
|
||||
if (result != null) {
|
||||
result.registerRafReleaser();
|
||||
// Ensure safe publication of a ChronicleMap
|
||||
OS.memory().storeFence();
|
||||
prepareMapPublication(result);
|
||||
} else {
|
||||
CanonicalRandomAccessFiles.release(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void prepareMapPublication(VanillaChronicleMap map) {
|
||||
// Ensure safe publication of a ChronicleMap
|
||||
OS.memory().storeFence();
|
||||
ChronicleMapCloseOnExitHook.add(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return size of the self bootstrapping header
|
||||
*/
|
||||
@@ -1669,8 +1674,7 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
lazyNativeBytesStoreWithFixedCapacity(map.sizeInBytesWithoutTiers());
|
||||
map.createMappedStoreAndSegments(bytesStore);
|
||||
establishReplication(map);
|
||||
// Ensure "safe publication" of a ChronicleMap
|
||||
OS.memory().storeFence();
|
||||
prepareMapPublication(map);
|
||||
return map;
|
||||
} catch (IOException e) {
|
||||
// file-less version should never trigger an IOException.
|
||||
|
||||
Reference in New Issue
Block a user