org.terracotta.offheapstore.storage.allocator
Class PowerOfTwoAllocator
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<T>
org.terracotta.offheapstore.util.AATreeSet<org.terracotta.offheapstore.storage.allocator.Region>
org.terracotta.offheapstore.storage.allocator.PowerOfTwoAllocator
- All Implemented Interfaces:
- Iterable<org.terracotta.offheapstore.storage.allocator.Region>, Collection<org.terracotta.offheapstore.storage.allocator.Region>, Set<org.terracotta.offheapstore.storage.allocator.Region>, SortedSet<org.terracotta.offheapstore.storage.allocator.Region>
public class PowerOfTwoAllocator
- extends AATreeSet<org.terracotta.offheapstore.storage.allocator.Region>
An augmented AA tree allocator with unusual alignment/allocation properties.
This allocator allocates only power-of-two size chunks. In addition these
chunks are then only allocated on alignment with their own size. Hence a
chunk of 2n size can only be allocated to an address satisfying
a=2nx where x is an integer.
- Author:
- Chris Dennis
|
Constructor Summary |
PowerOfTwoAllocator(int size)
Create a power-of-two allocator with the given initial 'free' size area. |
| Methods inherited from class org.terracotta.offheapstore.util.AATreeSet |
add, clear, comparator, first, getRoot, headSet, isEmpty, iterator, last, remove, size, subSet, tailSet |
PowerOfTwoAllocator
public PowerOfTwoAllocator(int size)
- Create a power-of-two allocator with the given initial 'free' size area.
- Parameters:
size - initial free size
allocate
public int allocate(int size,
PowerOfTwoAllocator.Packing packing)
free
public void free(int address,
int length)
tryFree
public void tryFree(int address,
int length)
find
public int find(int size,
PowerOfTwoAllocator.Packing packing)
claim
public void claim(int address,
int size)
occupied
public int occupied()
removeAndReturn
public org.terracotta.offheapstore.storage.allocator.Region removeAndReturn(Object o)
- Overrides:
removeAndReturn in class AATreeSet<org.terracotta.offheapstore.storage.allocator.Region>
find
public org.terracotta.offheapstore.storage.allocator.Region find(Object o)
- Overrides:
find in class AATreeSet<org.terracotta.offheapstore.storage.allocator.Region>
toString
public String toString()
-
- Overrides:
toString in class AbstractCollection<org.terracotta.offheapstore.storage.allocator.Region>
Copyright © 2015. All Rights Reserved.