Commit 0053c151 authored by Georgios Dagkakis's avatar Georgios Dagkakis

unneeded check in broker removed

parent ace10513
...@@ -91,49 +91,35 @@ class Broker(ObjectInterruption): ...@@ -91,49 +91,35 @@ class Broker(ObjectInterruption):
self.timeWaitForOperatorStarted=self.env.now self.timeWaitForOperatorStarted=self.env.now
#=============================================================== #===============================================================
from Globals import G from Globals import G
# if the victim does not have a dedicated operator
if not self.victim.checkForDedicatedOperators(): # if the victim already holds an entity that means that the machine's operation type
# if the victim already holds an entity that means that the machine's operation type # is no Load or setup, in that case the router is already invoked and the machine is already assigned an operator
# is no Load or setup, in that case the router is already invoked and the machine is already assigned an operator if not self.victimQueueIsEmpty():
if not self.victimQueueIsEmpty(): # add the currentEntity to the pendingEntities
# add the currentEntity to the pendingEntities if not self.victim.currentEntity in G.pendingEntities:
if not self.victim.currentEntity in G.pendingEntities: G.pendingEntities.append(self.victim.currentEntity)
G.pendingEntities.append(self.victim.currentEntity) if not G.RouterList[0].invoked and G.RouterList[0].expectedSignals['isCalled']:
if not G.RouterList[0].invoked and G.RouterList[0].expectedSignals['isCalled']: self.victim.printTrace(self.victim.id, signal='router (broker)')
self.victim.printTrace(self.victim.id, signal='router (broker)') self.sendSignal(receiver=G.RouterList[0], signal=G.RouterList[0].isCalled)
self.sendSignal(receiver=G.RouterList[0], signal=G.RouterList[0].isCalled) G.RouterList[0].invoked=True
G.RouterList[0].invoked=True
self.waitForOperator=True
self.victim.printTrace(self.victim.id, waitEvent='(resourceIsAvailable broker)')
self.expectedSignals['resourceAvailable']=1
yield self.resourceAvailable
transmitter, eventTime=self.resourceAvailable.value
self.resourceAvailable=self.env.event()
# remove the currentEntity from the pendingEntities
if self.victim.currentEntity in G.pendingEntities:
G.pendingEntities.remove(self.victim.currentEntity)
self.waitForOperator=False
self.victim.printTrace(self.victim.id, resourceAvailable='(broker)')
# else if the Router is already invoked for allocating purposes wait until a resource is allocated to the victim's operatorPool
# wait only if there is no current operator
# XXX discuss this
elif G.RouterList[0].invoked and G.RouterList[0].allocation and not self.victim.currentOperator:
self.waitForOperator=True self.waitForOperator=True
self.victim.printTrace(self.victim.id, waitEvent='(resourceIsAvailable broker)') self.victim.printTrace(self.victim.id, waitEvent='(resourceIsAvailable broker)')
self.expectedSignals['resourceAvailable']=1
if not self.victim.operatorPool.checkIfResourceIsAvailable(): yield self.resourceAvailable
self.expectedSignals['resourceAvailable']=1
yield self.resourceAvailable transmitter, eventTime=self.resourceAvailable.value
transmitter, eventTime=self.resourceAvailable.value self.resourceAvailable=self.env.event()
self.resourceAvailable=self.env.event() # remove the currentEntity from the pendingEntities
self.waitForOperator=False if self.victim.currentEntity in G.pendingEntities:
G.pendingEntities.remove(self.victim.currentEntity)
self.waitForOperator=False
self.victim.printTrace(self.victim.id, resourceAvailable='(broker)')
self.waitForOperator=False
#=============================================================== #===============================================================
assert self.victim.operatorPool.checkIfResourceIsAvailable(), 'there is no available operator to request' assert self.victim.operatorPool.checkIfResourceIsAvailable(), 'there is no available operator to request'
# set the available resource as the currentOperator # set the available resource as the currentOperator
currentOperator=None currentOperator=None
......
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