Quellcode durchsuchen

Take as much input/output as possible for each task

Yentl Van Tendeloo vor 8 Jahren
Ursprung
Commit
5680fcce22
1 geänderte Dateien mit 27 neuen und 20 gelöschten Zeilen
  1. 27 20
      hybrid_server/classes/mvkcontroller.xml

+ 27 - 20
hybrid_server/classes/mvkcontroller.xml

@@ -213,23 +213,22 @@
                 </state>
             </state>
 
-            <state id="execution">
+            <state id="execution" initial="execution">
                 <state id="execution">
                     <onentry>
                         <script>
+                            self.outputs = []
                             self.timeout = False
-                            self.destination = None
                             if self.tasks:
                                 task = self.tasks.pop()
                                 if not task in self.debugged_tasks or self.debug_info[task]['state'] == 'running':
                                     # Check if there are values to input
-                                    if self.input_queue[task]:
+                                    while self.input_queue[task]:
                                         source, args = self.input_queue[task].pop(0)
                                         for args_entry in args:
                                             self.execute_modelverse(task, "set_input", [args_entry])
 
-                                        self.destination = source
-                                        self.value = "OK"
+                                        self.outputs.append((source, "OK"))
                                         self.all_failed = False
 
                                     nr_of_steps = 1 if task in self.debugged_tasks else 100
@@ -244,15 +243,14 @@
                                         # Could at least execute one instruction, so mark it as "not failed"
                                         self.all_failed = False
 
-                                    # Check that we don't have anything to output yet, otherwise we wait
-                                    if self.destination is None:
-                                        # Perform output if there is anything
-                                        if self.output_queue[task]:
-                                            self.execute_modelverse(task, "get_output", [])
-                                            if self.mvk.success:
-                                                self.destination = self.output_queue[task].pop(0)
-                                                self.value = self.mvk.returnvalue
-                                                self.all_failed = False
+                                    # Perform output if there is anything
+                                    while self.output_queue[task]:
+                                        self.execute_modelverse(task, "get_output", [])
+                                        if self.mvk.success:
+                                            self.outputs.append((self.output_queue[task].pop(0), self.mvk.returnvalue))
+                                            self.all_failed = False
+                                        else:
+                                            break
 
                             else:
                                 if self.count >= 2000:
@@ -276,15 +274,24 @@
                         </script>
                     </onentry>
 
-                    <transition cond="self.destination is not None" after="self.sccd_yield()" target=".">
-                        <raise event="HTTP_input" scope="narrow" target="'to_mvi/%s' % self.destination">
-                            <parameter expr="json.dumps(self.value)"/>
+                    <transition cond="self.outputs" after="self.sccd_yield()" target="../process_data"/>
+
+                    <transition cond="self.timeout and not self.outputs" after="self.sccd_yield() + 0.10" target="."/>
+
+                    <transition cond="not self.timeout and not self.outputs" after="self.sccd_yield()" target="."/>
+                </state>
+
+                <state id="process_data">
+                    <transition cond="self.outputs" target=".">
+                        <script>
+                            destination, value = self.outputs.pop()
+                        </script>
+                        <raise event="HTTP_input" scope="narrow" target="'to_mvi/%s' % destination">
+                            <parameter expr="json.dumps(value)"/>
                         </raise>
                     </transition>
 
-                    <transition cond="self.timeout and self.destination is None" after="self.sccd_yield() + 0.10" target="."/>
-
-                    <transition cond="not self.timeout and self.destination is None" after="self.sccd_yield()" target="."/>
+                    <transition cond="not self.outputs" target="../execution"/>
                 </state>
             </state>