Broker signalling made more generic

parent 2e9e212c
...@@ -57,7 +57,7 @@ class ObjectInterruption(Process): ...@@ -57,7 +57,7 @@ class ObjectInterruption(Process):
# signalling can be done via Machine request/releaseOperator # signalling can be done via Machine request/releaseOperator
# ======================================================================= # =======================================================================
def invoke(self): def invoke(self):
self.brokerIsCalled.signal(now()) self.isCalled.signal(now())
# # ======================================================================= # # =======================================================================
# # return control to the Machine.run # # return control to the Machine.run
......
...@@ -48,7 +48,7 @@ class Broker(ObjectInterruption): ...@@ -48,7 +48,7 @@ class Broker(ObjectInterruption):
self.timeLastOperationEnded = 0 self.timeLastOperationEnded = 0
self.timeWaitForOperatorStarted=0 self.timeWaitForOperatorStarted=0
# Broker events # Broker events
self.brokerIsCalled=SimEvent('brokerIsCalled') self.isCalled=SimEvent('brokerIsCalled')
self.victimQueueIsEmpty=SimEvent('victimQueueIsEmpty') self.victimQueueIsEmpty=SimEvent('victimQueueIsEmpty')
self.resourceAvailable=SimEvent('resourceAvailable') self.resourceAvailable=SimEvent('resourceAvailable')
self.waitForOperator=False self.waitForOperator=False
...@@ -69,8 +69,8 @@ class Broker(ObjectInterruption): ...@@ -69,8 +69,8 @@ class Broker(ObjectInterruption):
def run(self): def run(self):
while 1: while 1:
# TODO: add new broker event - brokerIsCalled # TODO: add new broker event - brokerIsCalled
yield waitevent, self, self.brokerIsCalled yield waitevent, self, self.isCalled
assert self.brokerIsCalled.signalparam==now(), 'the broker should be granted control instantly' assert self.isCalled.signalparam==now(), 'the broker should be granted control instantly'
# ======= request a resource # ======= request a resource
if self.victim.isOperated()\ if self.victim.isOperated()\
and any(type=='Load' or type=='Setup' or type=='Processing'\ and any(type=='Load' or type=='Setup' or type=='Processing'\
...@@ -129,6 +129,7 @@ class Broker(ObjectInterruption): ...@@ -129,6 +129,7 @@ class Broker(ObjectInterruption):
yield release,self,self.victim.operatorPool.getResource(self.victim.currentOperator) yield release,self,self.victim.operatorPool.getResource(self.victim.currentOperator)
# signal the other brokers waiting for the same operators that they are now free # signal the other brokers waiting for the same operators that they are now free
# also signal the stations that were not requested to receive because the operator was occupied # also signal the stations that were not requested to receive because the operator was occupied
# self.victim.router.isCalled.signal(now())
self.signalLoadStations() self.signalLoadStations()
# # but now must have the option to proceed # # but now must have the option to proceed
......
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