summaryrefslogtreecommitdiff
path: root/esds
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-06-28 11:45:25 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2022-06-28 11:45:25 +0200
commit6b697fa14f01855a60a17a6ba3f52c55080e38c1 (patch)
treef49a9385f096f9ac2c354d9d02678594a91aa85e /esds
parent838e48438cf6597a172ea2af8749b68445bc30c6 (diff)
Refactoring
Diffstat (limited to 'esds')
-rw-r--r--esds/simulator.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/esds/simulator.py b/esds/simulator.py
index b65e5cf..324541c 100644
--- a/esds/simulator.py
+++ b/esds/simulator.py
@@ -123,7 +123,7 @@ class Simulator:
sorted_indexes=np.lexsort((self.events[:,3],self.events[:,1]))
self.events=self.events[sorted_indexes]
- def sync_node(self,node):
+ def sync_node_non_blocking(self,node):
"""
Process all call request and wait for Node.sync() to return
"""
@@ -263,7 +263,7 @@ class Simulator:
self.log("Interferences on "+interface,node=node)
return status
- def sync_event(self, node):
+ def sync_node_blocking(self, node):
"""
Collect events from the nodes
"""
@@ -283,8 +283,8 @@ class Simulator:
node["state"]="running"
node.rqueue.put(("receive",0))
# Do not forget to collect the next event. This is the only request which is processed here
- self.sync_node(node)
- self.sync_event(node)
+ self.sync_node_non_blocking(node)
+ self.sync_node_blocking(node)
elif node["request"] == "wait_end":
node["state"]="pending"
node.rqueue.put(("wait_end",0))
@@ -355,10 +355,10 @@ class Simulator:
while True:
# Synchronize every nodes
for node in self.nodes:
- self.sync_node(node)
+ self.sync_node_non_blocking(node)
# Manage events
for node in self.nodes:
- self.sync_event(node)
+ self.sync_node_blocking(node)
# Generate debug logs
if debug:
self.debug()
@@ -369,7 +369,7 @@ class Simulator:
for node_id in self.wait_end_nodes:
self.nodes[node_id]["state"]="running"
self.nodes[node_id].rqueue.put(("sim_end",0))
- self.sync_node(self.nodes[node_id]) # Allow them for make call requests (printing logs for example)
+ self.sync_node_non_blocking(self.nodes[node_id]) # Allow them for make call requests (printing logs for example)
break # End the event processing loop
# Update simulation time
@@ -396,7 +396,7 @@ class Simulator:
dst["interfaces_queue_size"][interface]-=1
dst["state"]="running"
dst.rqueue.put(("receive",0))
- self.sync_node(dst)
+ self.sync_node_non_blocking(dst)
src["state"]="running"
src.rqueue.put(("send",0))
else:
@@ -409,7 +409,7 @@ class Simulator:
dst["interfaces_queue_size"][interface]-=1
dst["state"]="running"
dst.rqueue.put(("receive",0))
- self.sync_node(dst)
+ self.sync_node_non_blocking(dst)
else:
src["state"]="running"
src.rqueue.put(("send",0))
@@ -417,7 +417,7 @@ class Simulator:
node=self.nodes[int(event)]
node["state"]="running"
node.rqueue.put(("timeout",0))
- self.sync_node(node)
+ self.sync_node_non_blocking(node)
elif event_type == 2 or event_type == 3:
breakpoint_callback(self)
if event_type == 3: