recalculate on allocation size change

This commit is contained in:
Leijurv 2018-11-24 11:32:23 -08:00
parent c79f40a5f1
commit 8ece179912
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
1 changed files with 6 additions and 1 deletions

View File

@ -32,7 +32,12 @@ public abstract class QuantizedTaskPriorityAllocationCache extends QuantizedTask
@Override
public final double priorityAllocatedTo(IQuantizedParentTaskRelationship child, int quantity) {
return allocationByQuantity.computeIfAbsent(quantity, this::allocationStrategy).allocatedTo(child);
Allocation allocation = allocationByQuantity.get(quantity);
if (allocation == null || allocation.total != effectiveAllocationSize(quantity)) {
allocation = allocationStrategy(quantity);
allocationByQuantity.put(quantity, allocation);
}
return allocation.allocatedTo(child);
}
protected Allocation allocationStrategy(int quantity) { // overridable