Package net.officefloor.server.stream
Interface StreamBufferPool<B>
-
- Type Parameters:
B- Type of buffer being pooled.
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
AbstractStreamBufferPool,MockStreamBufferPool,NettyBufferPool,ThreadLocalStreamBufferPool
public interface StreamBufferPool<B> extends java.lang.AutoCloseableProvides interface to wrap buffer pooling implementations.- Author:
- Daniel Sagenschneider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Closes pool releasing allStreamBufferinstances.StreamBuffer<B>getFileStreamBuffer(java.nio.channels.FileChannel file, long position, long count, FileCompleteCallback callback)Obtains aStreamBufferfor theFileChannelcontent.StreamBuffer<B>getPooledStreamBuffer()Obtains aStreamBuffer.StreamBuffer<B>getUnpooledStreamBuffer(java.nio.ByteBuffer buffer)Obtains anStreamBufferthat is not pooled.
-
-
-
Method Detail
-
getPooledStreamBuffer
StreamBuffer<B> getPooledStreamBuffer()
Obtains aStreamBuffer.- Returns:
StreamBuffer.
-
getUnpooledStreamBuffer
StreamBuffer<B> getUnpooledStreamBuffer(java.nio.ByteBuffer buffer)
Obtains an
StreamBufferthat is not pooled. This is forByteBufferinstances that are managed outside the BufferPool.Typical use is to create
StreamBufferfor some read-only cached content within aByteBuffer.- Parameters:
buffer-ByteBuffer.- Returns:
StreamBufferfor the unpooledByteBuffer.
-
getFileStreamBuffer
StreamBuffer<B> getFileStreamBuffer(java.nio.channels.FileChannel file, long position, long count, FileCompleteCallback callback) throws java.io.IOException
Obtains a
StreamBufferfor theFileChannelcontent.This enables efficient writing (ie DMA) of
FileChannelcontent.To write the entire
FileChannelcontents, invokewrite(file, 0, -1).Note that the underlying implementation will need to support
FileChannelefficiencies.- Parameters:
file-FileChannel.position- Position within theFileChannelto start writing content. Must be non-negative number.count- Count of bytes to write from theFileChannel. A negative value (typically-1) indicates to write the remainingFileChannelcontent from the position.callback- OptionalFileCompleteCallback. May benull.- Returns:
StreamBufferfor theFileChannel.- Throws:
java.io.IOException- If fails to create theStreamBufferfor theFileChannel. Typically, this is because the underlying implementation does not support DMA and copies the data from theFileChannel.
-
close
void close()
Closes pool releasing allStreamBufferinstances.- Specified by:
closein interfacejava.lang.AutoCloseable
-
-