sortCandidateEntities simplified

parent 2eca07ac
......@@ -64,7 +64,7 @@ class Operator(Repairman): # XXX isn't it the other way around ?
# TODO: clean the comments
# TODO: maybe the argument is not needed. the candidate entities is a variable of the object
# =======================================================================
def sortCandidateEntities(self, candidateEntities=[]):
def sortCandidateEntities(self):
pass
# # TODO: have to consider what happens in case of a critical order
# # FIFO sorting has no meaning when sorting candidateEntities
......
......@@ -71,22 +71,22 @@ class OperatorManagedJob(Operator):
# sorts the candidateEntities of the Operator according to the scheduling rule
# TODO: maybe the argument is not needed. the candidate entities is a variable of the object
# =======================================================================
def sortCandidateEntities(self, candidateEntities=[]):
def sortCandidateEntities(self):
# TODO: have to consider what happens in case of a critical order
#if we have sorting according to multiple criteria we have to call the sorter many times
if self.schedulingRule=="MC":
for criterion in reversed(self.multipleCriterionList):
self.activeCandidateQSorter(criterion=criterion, candidateEntities=candidateEntities)
self.activeCandidateQSorter(criterion=criterion)
#else we just use the default scheduling rule
else:
self.activeCandidateQSorter(self.schedulingRule, candidateEntities=candidateEntities)
self.activeCandidateQSorter(self.schedulingRule)
# =======================================================================
# sorts the Entities of the Queue according to the scheduling rule
# =======================================================================
# TODO: entityToGet is not updated for all stations, consider using it for all stations or withdraw the idea
def activeCandidateQSorter(self, criterion=None, candidateEntities=[]):
activeObjectQ=candidateEntities
def activeCandidateQSorter(self, criterion=None):
activeObjectQ=self.candidateEntities
if not activeObjectQ:
assert False, "empty candidate list"
if criterion==None:
......@@ -94,7 +94,7 @@ class OperatorManagedJob(Operator):
#if the schedulingRule is first in first out
if criterion=="FIFO":
# FIFO sorting has no meaning when sorting candidateEntities
self.activeCandidateQSorter('WT', candidateEntities=candidateEntities)
self.activeCandidateQSorter('WT')
# added for testing
# print 'there is no point of using FIFO scheduling rule for operators candidateEntities,\
# WT scheduling rule used instead'
......
......@@ -146,7 +146,7 @@ class Router(ObjectInterruption):
# check if the candidateReceivers are inPositionToGet and if they are already called
try:
receiverIsActive=(operator.candidateEntity.candidateReceiver in operator.activeCallersList\
and operator.candidateEntity.candidateReceiver in self.pendingObjects )
and operator.candidateEntity.candidateReceiver in self.pendingObjects )
except:
receiverIsActive=True
......@@ -277,6 +277,7 @@ class Router(ObjectInterruption):
del self.calledOperators[:]
del self.pendingObjects[:]
del self.multipleCriterionList[:]
# reset the call flag of the Router
self.call=False
#=======================================================================
......@@ -381,7 +382,7 @@ class Router(ObjectInterruption):
# sort the candidateEntities list of each operator according to its schedulingRule
for operator in [x for x in self.candidateOperators if x.candidateEntities]:
operator.sortCandidateEntities(operator.candidateEntities)
operator.sortCandidateEntities()
# if there operators that have only one option then sort the candidateOperators according to the first one of these
# TODO: find out what happens if there are many operators with one option
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment