mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Ensure safe publication of ChronicleMaps, created in ChronicleMapBuilder
This commit is contained in:
@@ -1501,6 +1501,8 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
} finally {
|
||||
if (result != null) {
|
||||
result.registerRafReleaser();
|
||||
// Ensure safe publication of a ChronicleMap
|
||||
OS.memory().storeFence();
|
||||
} else {
|
||||
CanonicalRandomAccessFiles.release(file);
|
||||
}
|
||||
@@ -1664,6 +1666,8 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
lazyNativeBytesStoreWithFixedCapacity(map.sizeInBytesWithoutTiers());
|
||||
map.createMappedStoreAndSegments(bytesStore);
|
||||
establishReplication(map);
|
||||
// Ensure "safe publication" of a ChronicleMap
|
||||
OS.memory().storeFence();
|
||||
return map;
|
||||
} catch (IOException e) {
|
||||
// file-less version should never trigger an IOException.
|
||||
|
||||
Reference in New Issue
Block a user