org.apache.directmemory.memory
Interface AllocationPolicy

All Known Implementing Classes:
RoundRobinAllocationPolicy

public interface AllocationPolicy

Interface describing the buffer allocation policy. The implementations will be initialized by setting the list of buffers init(List), and every allocation will call #getActiveBuffer(OffHeapMemoryBuffer, int), passing the previously (possibly null) buffer that failed to allocate and the number of the current allocation

Author:
bperroud

Method Summary
 ByteBufferAllocator getActiveAllocator(ByteBufferAllocator previousAllocator, int allocationNumber)
          Returns the ByteBufferAllocator to use to allocate.
 void init(List<ByteBufferAllocator> allocators)
          Initialization function.
 void reset()
          Reset internal state
 

Method Detail

init

void init(List<ByteBufferAllocator> allocators)
Initialization function.

Parameters:
buffers -

getActiveAllocator

ByteBufferAllocator getActiveAllocator(ByteBufferAllocator previousAllocator,
                                       int allocationNumber)
Returns the ByteBufferAllocator to use to allocate.

Parameters:
previousAllocator - : the previously used ByteBufferAllocator, or null if it's the first allocation
allocationNumber - : the number of time the allocation has already failed.
Returns:
the ByteBufferAllocator to use, or null if allocation has failed.

reset

void reset()
Reset internal state



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