T
- type of objects.public final class AllocationTable<T>
extends java.lang.Object
AllocationTable
implements a resource allocation table, which is a finite set of objects
(registers, pages, etc.) in couple with allocation / deallocation methods.Constructor and Description |
---|
AllocationTable(AllocationData<T> allocationData,
java.util.Collection<T> objects)
Constructs a resource allocation table.
|
AllocationTable(AllocationData<T> allocationData,
Supplier<T> supplier)
Constructs a resource allocation table.
|
Modifier and Type | Method and Description |
---|---|
T |
allocate(ResourceOperation operation,
java.util.Collection<T> retain,
java.util.Collection<T> exclude,
java.util.Map<ResourceOperation,java.lang.Integer> rate)
Allocates an object and marks it as being in use.
|
boolean |
exists(T object)
Checks whether the object exists in the allocation table.
|
void |
free(T object)
Frees (deallocates) the object.
|
AllocationData<T> |
getAllocationData()
Returns the default allocation data.
|
Supplier<T> |
getSupplier()
Returns the object generator.
|
T |
peek(java.util.Collection<T> retain,
java.util.Collection<T> exclude,
java.util.Map<ResourceOperation,java.lang.Integer> rate)
Peeks an object.
|
void |
reset()
Resets the resource allocation table.
|
void |
setAllocationData(AllocationData<T> allocationData)
Replaces the default allocation data.
|
java.lang.String |
toString() |
void |
use(ResourceOperation operation,
T object)
Marks the object as being in use.
|
public AllocationTable(AllocationData<T> allocationData, java.util.Collection<T> objects)
allocationData
- the allocation data.objects
- the available objects.public AllocationTable(AllocationData<T> allocationData, Supplier<T> supplier)
allocationData
- the allocation data.supplier
- the object generator.public AllocationData<T> getAllocationData()
public void setAllocationData(AllocationData<T> allocationData)
allocationData
- new allocation data.public void reset()
public boolean exists(T object)
object
- the object to be checked.true
if the object exists; false
otherwise.public void free(T object)
object
- the object to be freed.public void use(ResourceOperation operation, T object)
operation
- the operation on the object.object
- the object to be used.public T peek(java.util.Collection<T> retain, java.util.Collection<T> exclude, java.util.Map<ResourceOperation,java.lang.Integer> rate)
retain
- the objects that should be used for allocation.exclude
- the objects that should not be peeked.rate
- the dependencies biases.public T allocate(ResourceOperation operation, java.util.Collection<T> retain, java.util.Collection<T> exclude, java.util.Map<ResourceOperation,java.lang.Integer> rate)
operation
- the operation.retain
- the objects that should be used for allocation.exclude
- the objects that should not be allocated.rate
- the dependencies biases.public Supplier<T> getSupplier()
public java.lang.String toString()
toString
in class java.lang.Object