本文整理了Java中org.agrona.IoUtil.unmap()
方法的一些代码示例,展示了IoUtil.unmap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IoUtil.unmap()
方法的具体详情如下:
包路径:org.agrona.IoUtil
类名称:IoUtil
方法名:unmap
[英]Unmap a ByteBuffer without waiting for the next GC cycle if its memory mapped.
[中]如果ByteBuffer的内存已映射,则无需等待下一个GC循环即可取消其映射。
代码示例来源:origin: real-logic/aeron
private void closeRecordingSegment()
{
IoUtil.unmap(mappedSegmentBuffer);
mappedSegmentBuffer = null;
}
代码示例来源:origin: real-logic/agrona
public void close()
{
if (!isClosed)
{
if (null != mappedBuffer)
{
IoUtil.unmap(mappedBuffer);
}
isClosed = true;
}
}
代码示例来源:origin: real-logic/agrona
/**
* Unmap a {@link ByteBuffer} without waiting for the next GC cycle if its memory mapped.
*
* @param buffer to be unmapped.
*/
public static void unmap(final ByteBuffer buffer)
{
if (buffer instanceof MappedByteBuffer)
{
unmap((MappedByteBuffer)buffer);
}
}
代码示例来源:origin: real-logic/agrona
private void unmap()
{
IoUtil.unmap(fileChannel, addressOffset, capacity);
}
}
代码示例来源:origin: real-logic/aeron
/**
* Free up resources but don't delete files in case they are required for debugging.
*/
public void close()
{
final MappedByteBuffer lossReportBuffer = this.lossReportBuffer;
this.lossReportBuffer = null;
IoUtil.unmap(lossReportBuffer);
final MappedByteBuffer cncByteBuffer = this.cncByteBuffer;
this.cncByteBuffer = null;
IoUtil.unmap(cncByteBuffer);
super.close();
}
代码示例来源:origin: real-logic/aeron
public boolean free()
{
if (null != mappedBuffers)
{
for (final MappedByteBuffer buffer : mappedBuffers)
{
IoUtil.unmap(buffer);
}
mappedBuffers = null;
}
if (null != logFile)
{
if (!logFile.delete())
{
return false;
}
logFile = null;
}
return true;
}
代码示例来源:origin: real-logic/aeron
public void close()
{
CloseHelper.close(fileChannel);
for (final MappedByteBuffer buffer : mappedByteBuffers)
{
IoUtil.unmap(buffer);
}
}
代码示例来源:origin: real-logic/aeron
/**
* Clean up all resources that the client uses to communicate with the Media Driver.
*/
public void close()
{
final MappedByteBuffer cncByteBuffer = this.cncByteBuffer;
this.cncByteBuffer = null;
IoUtil.unmap(cncByteBuffer);
super.close();
}
代码示例来源:origin: real-logic/aeron
public void close()
{
if (!isClosed)
{
isClosed = true;
CloseHelper.close(catalogChannel);
IoUtil.unmap(catalogByteBuffer);
}
}
代码示例来源:origin: real-logic/aeron
/**
* Is a media driver active in the given directory?
*
* @param directory to check
* @param driverTimeoutMs for the driver liveness check.
* @param logger for feedback as liveness checked.
* @return true if a driver is active or false if not.
*/
public static boolean isDriverActive(
final File directory, final long driverTimeoutMs, final Consumer<String> logger)
{
final File cncFile = new File(directory, CncFileDescriptor.CNC_FILE);
if (cncFile.exists() && cncFile.length() > 0)
{
logger.accept("INFO: Aeron CnC file exists: " + cncFile);
final MappedByteBuffer cncByteBuffer = IoUtil.mapExistingFile(cncFile, "CnC file");
try
{
return isDriverActive(driverTimeoutMs, logger, cncByteBuffer);
}
finally
{
IoUtil.unmap(cncByteBuffer);
}
}
return false;
}
代码示例来源:origin: real-logic/aeron
/**
* Read the error log to a given {@link PrintStream}
*
* @param out to write the error log contents to.
* @return the number of observations from the error log.
*/
public int saveErrorLog(final PrintStream out)
{
final MappedByteBuffer cncByteBuffer = mapExistingCncFile(null);
try
{
return saveErrorLog(out, cncByteBuffer);
}
finally
{
IoUtil.unmap(cncByteBuffer);
}
}
代码示例来源:origin: real-logic/aeron
/**
* Is a media driver active in the current Aeron directory?
*
* @param driverTimeoutMs for the driver liveness check.
* @param logger for feedback as liveness checked.
* @return true if a driver is active or false if not.
*/
public boolean isDriverActive(final long driverTimeoutMs, final Consumer<String> logger)
{
final MappedByteBuffer cncByteBuffer = mapExistingCncFile(logger);
try
{
return isDriverActive(driverTimeoutMs, logger, cncByteBuffer);
}
finally
{
IoUtil.unmap(cncByteBuffer);
}
}
代码示例来源:origin: real-logic/agrona
IoUtil.unmap(byteBuffer);
代码示例来源:origin: real-logic/agrona
IoUtil.unmap(byteBuffer);
代码示例来源:origin: real-logic/aeron
private void fileChunk(
final long correlationId,
final long chunkOffset,
final long chunkLength,
final DirectBuffer buffer,
final int offset)
{
final UnsafeBuffer fileBuffer = fileSessionByIdMap.get(correlationId);
buffer.getBytes(offset + CHUNK_PAYLOAD_OFFSET, fileBuffer, (int)chunkOffset, (int)chunkLength);
if ((chunkOffset + chunkLength) >= fileBuffer.capacity())
{
fileSessionByIdMap.remove(correlationId);
IoUtil.unmap(fileBuffer.byteBuffer());
}
}
代码示例来源:origin: real-logic/aeron
private static void ensureDirectoryIsRecreated(final Context ctx)
{
if (ctx.aeronDirectory().isDirectory())
{
if (ctx.warnIfDirectoryExists())
{
System.err.println("WARNING: " + ctx.aeronDirectory() + " already exists.");
}
if (!ctx.dirDeleteOnStart())
{
final Consumer<String> logger = ctx.warnIfDirectoryExists() ? System.err::println : (s) -> {};
final MappedByteBuffer cncByteBuffer = ctx.mapExistingCncFile(logger);
try
{
if (CommonContext.isDriverActive(ctx.driverTimeoutMs(), logger, cncByteBuffer))
{
throw new ActiveDriverException("active driver detected");
}
reportExistingErrors(ctx, cncByteBuffer);
}
finally
{
IoUtil.unmap(cncByteBuffer);
}
}
ctx.deleteAeronDirectory();
}
IoUtil.ensureDirectoryExists(ctx.aeronDirectory(), "aeron");
}
代码示例来源:origin: real-logic/aeron
@After
public void after()
{
IoUtil.unmap(mockLogBufferMapped.byteBuffer());
CloseHelper.close(mockLogBufferChannel);
IoUtil.delete(archiveDir, false);
IoUtil.delete(termFile, false);
}
代码示例来源:origin: real-logic/aeron
IoUtil.unmap(cncByteBuffer);
cncByteBuffer = null;
cncMetaDataBuffer = null;
代码示例来源:origin: org.agrona/agrona
/**
* Unmap a {@link ByteBuffer} without waiting for the next GC cycle if its memory mapped.
*
* @param buffer to be unmapped.
*/
public static void unmap(final ByteBuffer buffer)
{
if (buffer instanceof MappedByteBuffer)
{
unmap((MappedByteBuffer)buffer);
}
}
代码示例来源:origin: zeebe-io/zeebe
public void closeSegment() {
if (fileChannel.isOpen()) {
try {
this.metadataSection = null;
IoUtil.unmap(mappedBuffer);
fileChannel.close();
} catch (IOException e) {
LOG.error("Failed to close segment", e);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!