org.apache.directmemory.memory
Class RoundRobinAllocationPolicy

java.lang.Object
  extended by org.apache.directmemory.memory.RoundRobinAllocationPolicy
All Implemented Interfaces:
AllocationPolicy

public class RoundRobinAllocationPolicy
extends Object
implements AllocationPolicy

Round Robin allocation policy. An internal counter is incremented (modulo the size of the buffer), so each calls to #getActiveBuffer(OffHeapMemoryBuffer, int) will increment the counter and return the buffer at the index of the counter.

Author:
bperroud

Constructor Summary
RoundRobinAllocationPolicy()
           
 
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
 void setMaxAllocations(int maxAllocations)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoundRobinAllocationPolicy

public RoundRobinAllocationPolicy()
Method Detail

setMaxAllocations

public void setMaxAllocations(int maxAllocations)

init

public void init(List<ByteBufferAllocator> allocators)
Description copied from interface: AllocationPolicy
Initialization function.

Specified by:
init in interface AllocationPolicy

getActiveAllocator

public ByteBufferAllocator getActiveAllocator(ByteBufferAllocator previousAllocator,
                                              int allocationNumber)
Description copied from interface: AllocationPolicy
Returns the ByteBufferAllocator to use to allocate.

Specified by:
getActiveAllocator in interface AllocationPolicy
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

public void reset()
Description copied from interface: AllocationPolicy
Reset internal state

Specified by:
reset in interface AllocationPolicy


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