瀏覽代碼

Only break while after 20 iterations, to keep overhead lower

Yentl Van Tendeloo 7 年之前
父節點
當前提交
605a7a15c0
共有 3 個文件被更改,包括 9 次插入4 次删除
  1. 1 1
      hybrid_server/classes/mvkcontroller.xml
  2. 7 2
      kernel/modelverse_kernel/main.py
  3. 1 1
      wrappers/modelverse_SCCD.py

+ 1 - 1
hybrid_server/classes/mvkcontroller.xml

@@ -321,7 +321,7 @@
                             </script>
                             <raise scope="broad" event="resume_task"/>
                         </onentry>
-                        <transition after="self.sccd_yield() + 100" target="."/>
+                        <transition after="self.sccd_yield() + 600" target="."/>
                     </state>
                 </state>
             </parallel>

+ 7 - 2
kernel/modelverse_kernel/main.py

@@ -351,15 +351,20 @@ class ModelverseKernel(object):
                                 ("RD", [inst, "body"])]
             (prev_cond, instruction_cond), = yield [("CALL_ARGS", [self.print_instruction, (cond, 0, indent+1)])]
             (prev_body, instruction_body), = yield [("CALL_ARGS", [self.print_instruction, (body, indent+1)])]
-            instruction = "  " * indent + "while 1:\n" + prev_cond + \
+            instruction = "  " * indent + "__counter_%s = 0\n" % inst + \
+                          "  " * indent + "while 1:\n" + prev_cond + \
                           "  " * (indent + 1) + "if 'value' not in %s:\n" % instruction_cond + \
                           "  " * (indent + 2) + "%s['value'], = yield [('RV', [%s['id']])]\n" % (instruction_cond, instruction_cond) + \
                           "  " * (indent + 1) + "if not (%s['value']):\n" % instruction_cond + \
                           "  " * (indent + 2) + "break\n" + \
                           "  " * (indent + 1) + "else:\n" + \
-                          "  " * (indent + 2) + "yield None\n" + \
+                          "  " * (indent + 2) + "__counter_%s += 1\n" % inst + \
+                          "  " * (indent + 2) + "if __counter_%s > 20:\n" % inst + \
+                          "  " * (indent + 3) + "yield None\n" + \
+                          "  " * (indent + 3) + "__counter_%s = 0\n" % inst + \
                           prev_body + instruction_body
 
+
         next_inst, = yield [("RD", [inst, "next"])]
         if next_inst:
             (prev_next, inst_next), = yield [("CALL_ARGS", [self.print_instruction, (next_inst, indent)])]

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed May 23 09:21:50 2018
+Date:   Wed May 23 09:41:55 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server