Refactor code for allocating previously unscheduled elements
Once all new allocations are done, originally unschedule elements are unschedule/schedule again, to force dependencies are satisfy FEA: ItEr66OTS03AlgoritmosLimitantesItEr65OTS05
This commit is contained in:
parent
d7d552c07c
commit
fbe21f9f4b
1 changed files with 26 additions and 19 deletions
|
|
@ -433,10 +433,33 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
|
|||
.getPotentiallyAffectedByInsertion(externalQueueElement),
|
||||
requirements.getElement(), allocation);
|
||||
result.addAll(moved);
|
||||
result.addAll(scheduleUnscheduledElementsIfNeeded(allocation));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Collection<? extends LimitingResourceQueueElement> scheduleUnscheduledElementsIfNeeded(
|
||||
AllocationSpec allocation) {
|
||||
|
||||
List<LimitingResourceQueueElement> result = new ArrayList<LimitingResourceQueueElement>();
|
||||
|
||||
// Return all moved tasks (including the allocated one)
|
||||
if (allocation.isAppropriative()) {
|
||||
result.addAll(scheduleElements(allocation.getUnscheduledElements()));
|
||||
checkAllocationIsAppropriative(false);
|
||||
|
||||
// Assign all unscheduled elements
|
||||
List<LimitingResourceQueueElement> unscheduled = allocation.getUnscheduledElements();
|
||||
for (LimitingResourceQueueElement each: unscheduled) {
|
||||
result.addAll(assignLimitingResourceQueueElement(each));
|
||||
}
|
||||
|
||||
// Only for those originally unscheduled elements, unschedule and
|
||||
// schedule them again to force dependencies are satisfied
|
||||
for (LimitingResourceQueueElement each: unscheduled) {
|
||||
unschedule(each);
|
||||
assignLimitingResourceQueueElement(each);
|
||||
}
|
||||
|
||||
checkAllocationIsAppropriative(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -780,24 +803,8 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
|
|||
queuesState.getPotentiallyAffectedByInsertion(element),
|
||||
requirements.getElement(), allocation);
|
||||
result.addAll(moved);
|
||||
result.addAll(scheduleUnscheduledElementsIfNeeded(allocation));
|
||||
|
||||
// Return all moved tasks (including the allocated one)
|
||||
if (allocation.isAppropriative()) {
|
||||
result.addAll(scheduleElements(allocation.getUnscheduledElements()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<LimitingResourceQueueElement> scheduleElements(
|
||||
List<LimitingResourceQueueElement> unscheduled) {
|
||||
|
||||
List<LimitingResourceQueueElement> result = new ArrayList<LimitingResourceQueueElement>();
|
||||
|
||||
checkAllocationIsAppropriative(false);
|
||||
for (LimitingResourceQueueElement each: unscheduled) {
|
||||
result.addAll(assignLimitingResourceQueueElement(each));
|
||||
}
|
||||
checkAllocationIsAppropriative(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue