public class BufferManager extends java.lang.Object
Buffers are acquired using
createBuffer(), and should be
disposed of using
disposeBuffer(java.nio.ByteBuffer) when no longer in use.
When none of the buffers are in use any more,
Note: the mapped buffer is unmapped using
Unmapper when all created buffers have been disposed,
or when close() is called.
If any of the created buffers is used after this has happened,
and unmapping is actually attempted, very bad consequences may ensue.
Therefore this class, or at least its
close() methods, should be used with extreme caution,
or a null Unmapper should be supplied.
|Constructor and Description|
|Modifier and Type||Method and Description|
Asserts that neither this manager, nor any of the buffers it has supplied, will be used again.
Returns a new read-only ByteBuffer providing access to the file region.
Asserts that the supplied buffer, originally acquired from
public BufferManager(java.nio.channels.FileChannel channel, long offset, int leng, java.lang.String logLabel, Unmapper unmapper)
channel- file channel
offset- offset into file of start of mapped region
leng- length of mapped region
logLabel- description of mapped region suitable for use in logging messages
unmapper- used to unmap buffers, may be null for safety
public java.nio.ByteBuffer createBuffer() throws java.io.IOException
disposeBuffer(java.nio.ByteBuffer)after it is known that it will no longer be used.
public void disposeBuffer(java.nio.ByteBuffer buf)
createBuffer(), will no longer be used. Resources may be reclaimed.
buf- previously created buffer
public void close()