Class AbstractStreamBufferPool<B>
- java.lang.Object
-
- net.officefloor.server.stream.impl.AbstractStreamBufferPool<B>
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,StreamBufferPool<B>
- Direct Known Subclasses:
ThreadLocalStreamBufferPool
public abstract class AbstractStreamBufferPool<B> extends java.lang.Object implements StreamBufferPool<B>
AbstractStreamBufferPool
.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractStreamBufferPool.FileStreamBuffer
FileChannel
StreamBuffer
.protected class
AbstractStreamBufferPool.UnpooledStreamBuffer
UnpooledStreamBuffer
.
-
Constructor Summary
Constructors Constructor Description AbstractStreamBufferPool()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StreamBuffer<B>
getFileStreamBuffer(java.nio.channels.FileChannel file, long position, long count, FileCompleteCallback callback)
Obtains aStreamBuffer
for theFileChannel
content.StreamBuffer<B>
getUnpooledStreamBuffer(java.nio.ByteBuffer buffer)
Obtains anStreamBuffer
that is not pooled.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.officefloor.server.stream.StreamBufferPool
close, getPooledStreamBuffer
-
-
-
-
Method Detail
-
getUnpooledStreamBuffer
public StreamBuffer<B> getUnpooledStreamBuffer(java.nio.ByteBuffer buffer)
Description copied from interface:StreamBufferPool
Obtains an
StreamBuffer
that is not pooled. This is forByteBuffer
instances that are managed outside the BufferPool.Typical use is to create
StreamBuffer
for some read-only cached content within aByteBuffer
.- Specified by:
getUnpooledStreamBuffer
in interfaceStreamBufferPool<B>
- Parameters:
buffer
-ByteBuffer
.- Returns:
StreamBuffer
for the unpooledByteBuffer
.
-
getFileStreamBuffer
public StreamBuffer<B> getFileStreamBuffer(java.nio.channels.FileChannel file, long position, long count, FileCompleteCallback callback)
Description copied from interface:StreamBufferPool
Obtains a
StreamBuffer
for theFileChannel
content.This enables efficient writing (ie DMA) of
FileChannel
content.To write the entire
FileChannel
contents, invokewrite(file, 0, -1)
.Note that the underlying implementation will need to support
FileChannel
efficiencies.- Specified by:
getFileStreamBuffer
in interfaceStreamBufferPool<B>
- Parameters:
file
-FileChannel
.position
- Position within theFileChannel
to 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 remainingFileChannel
content from the position.callback
- OptionalFileCompleteCallback
. May benull
.- Returns:
StreamBuffer
for theFileChannel
.
-
-