Java Code Examples for net.openhft.chronicle.core.OS#pageAlign()
The following examples show how to use
net.openhft.chronicle.core.OS#pageAlign() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RollEOFTest.java From Chronicle-Queue with Apache License 2.0 | 6 votes |
private void removeEOF(Path path) throws IOException { long blockSize = 64 << 10; long chunkSize = OS.pageAlign(blockSize); long overlapSize = OS.pageAlign(blockSize / 4); final MappedBytes mappedBytes = MappedBytes.mappedBytes(path.toFile(), chunkSize, overlapSize, false); mappedBytes.reserve(test); try { final Wire wire = WireType.BINARY_LIGHT.apply(mappedBytes); final Bytes<?> bytes = wire.bytes(); bytes.readLimitToCapacity(); bytes.readSkip(4); // move past header try (final SingleChronicleQueueStore qs = loadStore(wire)) { assertNotNull(qs); long l = qs.writePosition(); long len = Wires.lengthOf(bytes.readVolatileInt(l)); long eofOffset = l + len + 4L; bytes.writePosition(eofOffset); bytes.writeInt(0); } } finally { mappedBytes.release(test); } }
Example 2
Source File: VanillaChronicleHash.java From Chronicle-Map with Apache License 2.0 | 5 votes |
private void msync(long address, long length) throws IOException { // address should be a multiple of page size if (OS.pageAlign(address) != address) { long oldAddress = address; address = OS.pageAlign(address) - OS.pageSize(); length += oldAddress - address; } if (OS.isWindows()) { WindowsMsync.msync(raf, address, length); } else { PosixMsync.msync(address, length); } }
Example 3
Source File: SingleChronicleQueue.java From Chronicle-Queue with Apache License 2.0 | 5 votes |
@NotNull @PackageLocal MappedFile mappedFile(File file) throws FileNotFoundException { long chunkSize = OS.pageAlign(blockSize); long overlapSize = OS.pageAlign(blockSize / 4); return MappedFile.of(file, chunkSize, overlapSize, readOnly); }