From 16358d5728e9d560d4395c2de2616bc6180e9700 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Thu, 8 Sep 2022 07:42:22 +0200 Subject: Cleaning plugin management code --- esds/simulator.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'esds/simulator.py') diff --git a/esds/simulator.py b/esds/simulator.py index aa6573b..4f2eb71 100644 --- a/esds/simulator.py +++ b/esds/simulator.py @@ -202,7 +202,7 @@ class Simulator: else: selector_wireless.append(True) selector_wired.append(False) - self.notify_node_plugins(self.nodes[int(event[2][1])], "on_communication_end", (self.time,event)) + self.notify_node_plugins(self.nodes[int(event[2][1])], "on_communication_end", event) else: selector_wireless.append(False) selector_wired.append(False) @@ -235,7 +235,7 @@ class Simulator: selector.append(True) if self.netmat[event[2][2]]["is_wired"]: sharing_to_update.append((int(event[2][1]),event[2][2])) - self.notify_node_plugins(node, "on_communication_end", (self.time,event)) + self.notify_node_plugins(node, "on_communication_end", event) else: selector.append(False) self.events=self.events[~np.array(selector)] @@ -359,10 +359,7 @@ class Simulator: def notify_node_plugins(self,node,callback,args): node["pending_plugin_notify"]+=1 - node.rqueue.put(("plugin_notify",callback,args)) - # Now ensure that all callbacks are called before continuing - while node["pending_plugin_notify"] > 0: - pass + node.rqueue.put(("plugin_notify",callback,self.time,args)) def add_event(self,event_type,event_ts,event,priority=2): """ @@ -438,13 +435,13 @@ class Simulator: dst["state"]="running" dst.rqueue.put(("receive",0)) self.sync_node_non_blocking(dst,timeout_remove_only=True) - self.notify_node_plugins(dst, "on_communication_end", (self.time,event)) + self.notify_node_plugins(dst, "on_communication_end", event) self.update_sharing(dst.node_id,-1,interface) src["state"]="running" code=0 if perform_delivery else 1 src.rqueue.put(("send",code)) self.sync_node_non_blocking(src,timeout_remove_only=True) - self.notify_node_plugins(src, "on_communication_end", (self.time,event)) + self.notify_node_plugins(src, "on_communication_end", event) else: if src.node_id != dst.node_id: if perform_delivery: @@ -457,12 +454,12 @@ class Simulator: dst["state"]="running" dst.rqueue.put(("receive",0)) self.sync_node_non_blocking(dst,timeout_remove_only=True) - self.notify_node_plugins(dst, "on_communication_end", (self.time,event)) + self.notify_node_plugins(dst, "on_communication_end", event) else: src["state"]="running" src.rqueue.put(("send",0)) self.sync_node_non_blocking(src,timeout_remove_only=True) - self.notify_node_plugins(src, "on_communication_end", (self.time,event)) + self.notify_node_plugins(src, "on_communication_end", event) elif event_type == 1: # Timeout node=self.nodes[int(event)] node["state"]="running" -- cgit v1.2.3