public interface IBufferAccess
ByteBuffer
managed
by the DirectBufferPool
. A "direct" buffer is a region from the C
heap of the native JVM process. Such buffers can be efficient for NIO. They
are also efficient when the application needs to store large amounts of data
without putting pressure on the Garbage Collector.
CAUTION: Applications MUST use specific patterns when they work with
the DirectBufferPool
Applications which acquire an
IBufferAccess
object MUST hold a hard reference to that
IBufferAccess
while they are using the associated memory block.
Failure to follow this pattern WILL result in the backing ByteBuffer
being returned to the DirectBufferPool
while the application is still
using the ByteBuffer
(GC will drive this). This situation will lead
to corruption for data stored within the ByteBuffer
if the buffer
recycled and handed off once again via DirectBufferPool.acquire()
.
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
buffer()
Return the direct
ByteBuffer . |
void |
release()
Release the
ByteBuffer , returning to owning pool. |
void |
release(long timeout,
TimeUnit unit)
Release the
ByteBuffer , returning to owning pool. |
ByteBuffer buffer()
ByteBuffer
.
Caution: DO NOT hold onto a reference to the returned
ByteBuffer
without also retaining the IBufferAccess
object. This can cause the backing ByteBuffer
to be returned to
the pool, after which it may be handed off to another thread leading to
data corruption through concurrent modification to the backing bytes!
IllegalStateException
- if the buffer has been released.void release() throws InterruptedException
ByteBuffer
, returning to owning pool. This method
will silently succeed if the buffer has already been released.InterruptedException
- if an interrupt is noticed while attempting to return the
buffer to the pool.void release(long timeout, TimeUnit unit) throws InterruptedException
ByteBuffer
, returning to owning pool. This method
will silently succeed if the buffer has already been released.timeout
- The timeout.unit
- The units for that timeout.InterruptedException
- if an interrupt is noticed while attempting to return the
buffer to the pool.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.