org.terracotta.offheapstore.storage.allocator
Class IntegerBestFitAllocator

java.lang.Object
  extended by org.terracotta.offheapstore.storage.allocator.IntegerBestFitAllocator
All Implemented Interfaces:
Iterable<Long>, Allocator

public final class IntegerBestFitAllocator
extends Object
implements Allocator

An aggressively best-fit allocator.

Author:
Chris Dennis

Constructor Summary
IntegerBestFitAllocator(OffHeapStorageArea storage)
          Create a best fit allocator backed by the given OffHeapStorageArea.
 
Method Summary
 long allocate(long size)
           
 void clear()
           
 void expand(long increase)
           
 void free(long address)
           
 long getLastUsedAddress()
           
 long getLastUsedPointer()
           
 long getMaximumAddress()
           
 int getMinimalSize()
           
 Iterator<Long> iterator()
           
 long occupied()
           
 String toString()
           
 void validateAllocator()
          Debugging Support
 int validateMallocedPointer(int m)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntegerBestFitAllocator

public IntegerBestFitAllocator(OffHeapStorageArea storage)
Create a best fit allocator backed by the given OffHeapStorageArea.

Parameters:
storage - source of ByteBuffer instances
Method Detail

clear

public void clear()
Specified by:
clear in interface Allocator

expand

public void expand(long increase)
Specified by:
expand in interface Allocator

allocate

public long allocate(long size)
Specified by:
allocate in interface Allocator

free

public void free(long address)
Specified by:
free in interface Allocator

occupied

public long occupied()
Specified by:
occupied in interface Allocator

toString

public String toString()
Overrides:
toString in class Object

validateAllocator

public void validateAllocator()
Debugging Support

Specified by:
validateAllocator in interface Allocator

validateMallocedPointer

public int validateMallocedPointer(int m)

getLastUsedPointer

public long getLastUsedPointer()
Specified by:
getLastUsedPointer in interface Allocator

getLastUsedAddress

public long getLastUsedAddress()
Specified by:
getLastUsedAddress in interface Allocator

getMinimalSize

public int getMinimalSize()
Specified by:
getMinimalSize in interface Allocator

getMaximumAddress

public long getMaximumAddress()
Specified by:
getMaximumAddress in interface Allocator

iterator

public Iterator<Long> iterator()
Specified by:
iterator in interface Iterable<Long>


Copyright © 2016. All Rights Reserved.