resume task with list datastructure

parent f636f76c
......@@ -62,7 +62,7 @@ class Network():
def simulate(self,time):
# logger.info("simulating .. ")
self.networkClockTime = time
# Note links should be simulated before nodes
# Note links should be simulated before nodeself.ResumeTasks.append(("nextOn", self.startNodeLifeCycleGenerator,))s
# in order to receive the messge which is supposed to be received in this tick
for link in self.links.values():
link.simulate(time)
......
......@@ -86,6 +86,19 @@ class Node(SystemEntity):
# check if main ba* has to be resumed or not
try:
ResumeTask = self.ResumeTasks.pop(0)
command = self.commands.get(ResumeTask[0])
ResumeOut = command(time,ResumeTask[1:])
if ResumeOut and ResumeOut[0] == "resume":
self.logger.info("resume has been called")
self.ResumeTasks.append(("nextOn", self.startNodeLifeCycleGenerator,))
except KeyError as ke:
# not task pending at this time
pass
except StopIteration as si:
pass
# TODO : perform task from todolist which are relevant for current tick
......
......@@ -10,7 +10,8 @@ class OverlayNode(Node):
Node.__init__(self,id,network,weight)
self.startNodeLifeCycleGenerator = self.startNodeLifeCycle()
# adding initial task of bootstraping node.
self.todoList['0'].append(("nextOn", self.startNodeLifeCycleGenerator,))
self.ResumeTasks.append(("nextOn", self.startNodeLifeCycleGenerator,))
# self.todoList['0'].append(("nextOn", self.startNodeLifeCycleGenerator,))
self.commands.update({})
def processMessage(self,time,payload):
......
......@@ -42,6 +42,9 @@ def simulateNetwork(net):
if __name__ == '__main__':
logging.basicConfig(filename='TestCases.log', level=logging.INFO)
# populateTodolist(None)
simulateNetwork(None)
# simulateNetwork(None)
ak = ['hello','ramesh']
ak.append('rao')
print(ak.pop())
pass
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