org.apache.directmemory.memory.allocator
Interface ByteBufferAllocator

All Superinterfaces:
Closeable
All Known Implementing Classes:
AbstractByteBufferAllocator, FixedSizeByteBufferAllocatorImpl, MergingByteBufferAllocatorImpl, SlabByteBufferAllocatorImpl

public interface ByteBufferAllocator
extends Closeable

Interface defining interaction with ByteBuffer

Since:
0.6

Method Summary
 ByteBuffer allocate(int size)
          Allocates and returns a ByteBuffer with Buffer.limit() set to the given size.
 void clear()
          Clear all allocated ByteBuffer, resulting in a empty and ready to deserve ByteBufferAllocator
 void free(ByteBuffer buffer)
          Returns the given ByteBuffer making it available for a future usage.
 int getCapacity()
           
 int getNumber()
           
 
Methods inherited from interface java.io.Closeable
close
 

Method Detail

free

void free(ByteBuffer buffer)
Returns the given ByteBuffer making it available for a future usage. Returning twice a ByteBuffer won't throw an exception.

Parameters:
buffer - : the ByteBuffer to return

allocate

ByteBuffer allocate(int size)
Allocates and returns a ByteBuffer with Buffer.limit() set to the given size. When the allocation fails, it returns either null or throws an BufferOverflowException, depending on the implementation.

Parameters:
size - : the size in byte to allocate
Returns:
a ByteBuffer of the given size, or either return null or throw an BufferOverflowException when the allocation fails.

clear

void clear()
Clear all allocated ByteBuffer, resulting in a empty and ready to deserve ByteBufferAllocator


getCapacity

int getCapacity()
Returns:
the internal total size that can be allocated

getNumber

int getNumber()
Returns:
the internal identifier of the ByteBufferAllocator


Copyright © 2011-2012 The Apache Software Foundation. All Rights Reserved.