XNIO API 3.0.7.GA

org.xnio
Class ByteBufferSlicePool

java.lang.Object
  extended by org.xnio.ByteBufferSlicePool
All Implemented Interfaces:
Pool<ByteBuffer>

public final class ByteBufferSlicePool
extends Object
implements Pool<ByteBuffer>

A buffer pooled allocator. This pool uses a series of buffer regions to back the returned pooled buffers. When the buffer is no longer needed, it should be freed back into the pool; failure to do so will cause the corresponding buffer area to be unavailable until the buffer is garbage-collected.

Author:
David M. Lloyd

Constructor Summary
ByteBufferSlicePool(BufferAllocator<ByteBuffer> allocator, int bufferSize, int maxRegionSize)
          Construct a new instance.
ByteBufferSlicePool(int bufferSize, int maxRegionSize)
          Construct a new instance, using a direct buffer allocator.
 
Method Summary
 Pooled<ByteBuffer> allocate()
          Allocate a resource from the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteBufferSlicePool

public ByteBufferSlicePool(BufferAllocator<ByteBuffer> allocator,
                           int bufferSize,
                           int maxRegionSize)
Construct a new instance.

Parameters:
allocator - the buffer allocator to use
bufferSize - the size of each buffer
maxRegionSize - the maximum region size for each backing buffer

ByteBufferSlicePool

public ByteBufferSlicePool(int bufferSize,
                           int maxRegionSize)
Construct a new instance, using a direct buffer allocator.

Parameters:
bufferSize - the size of each buffer
maxRegionSize - the maximum region size for each backing buffer
Method Detail

allocate

public Pooled<ByteBuffer> allocate()
Allocate a resource from the pool.

Specified by:
allocate in interface Pool<ByteBuffer>
Returns:
the resource

XNIO API 3.0.7.GA

Copyright © 2010 JBoss, a division of Red Hat, Inc.