org.apache.directmemory.memory.allocator
Class SlabByteBufferAllocatorImpl
java.lang.Object
org.apache.directmemory.memory.allocator.AbstractByteBufferAllocator
org.apache.directmemory.memory.allocator.SlabByteBufferAllocatorImpl
- All Implemented Interfaces:
- Closeable, ByteBufferAllocator
public class SlabByteBufferAllocatorImpl
- extends AbstractByteBufferAllocator
ByteBufferAllocator implementation that uses FixedSizeByteBufferAllocatorImpl
of different size to allocate best matching's size ByteBuffer
- Since:
- 0.6
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SlabByteBufferAllocatorImpl
public SlabByteBufferAllocatorImpl(int number,
Collection<FixedSizeByteBufferAllocatorImpl> slabs,
boolean allowAllocationToBiggerSlab)
- Constructor.
- Parameters:
number - : internal allocator identifierslabs - : FixedSizeByteBufferAllocatorImpl to use for allocationallowAllocationToBiggerSlab - : tells if it is allowed to look in a bigger slab to perform the request.
free
public void free(ByteBuffer byteBuffer)
- Description copied from interface:
ByteBufferAllocator
- Returns the given
ByteBuffer making it available for a future usage. Returning twice a ByteBuffer won't throw an exception.
- Parameters:
byteBuffer - : the ByteBuffer to return
allocate
public ByteBuffer allocate(int size)
- Description copied from interface:
ByteBufferAllocator
- 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
public void clear()
- Description copied from interface:
ByteBufferAllocator
- Clear all allocated
ByteBuffer, resulting in a empty and ready to deserve ByteBufferAllocator
getCapacity
public int getCapacity()
- Returns:
- the internal total size that can be allocated
close
public void close()
throws IOException
- Throws:
IOException
Copyright © 2011-2012 The Apache Software Foundation. All Rights Reserved.