Commit bfdcac3c authored by Georgios Dagkakis's avatar Georgios Dagkakis

SelectiveQueue to work as normal if successors have the same priority

parent 9f2208be
...@@ -4,6 +4,9 @@ from dream.simulation.imports import Queue ...@@ -4,6 +4,9 @@ from dream.simulation.imports import Queue
class SelectiveQueue(Queue): class SelectiveQueue(Queue):
#override so that it chooses receiver according to priority #override so that it chooses receiver according to priority
def selectReceiver(self,possibleReceivers=[]): def selectReceiver(self,possibleReceivers=[]):
#if the priorities are the same work as cycle
if possibleReceivers[0].priority==possibleReceivers[1].priority:
return Queue.selectReceiver(possibleReceivers)
# sort the receivers according to their priority # sort the receivers according to their priority
possibleReceivers.sort(key=lambda x: x.priority, reverse=True) possibleReceivers.sort(key=lambda x: x.priority, reverse=True)
if possibleReceivers[0].canAccept(): if possibleReceivers[0].canAccept():
......
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