This will start emulation until all tasks get done. count: Stop after sceduling *count* times. <=0 disables this check. timeout: Stop after *timeout* ms. <=0 disables this check.
(self, count: int = 0, timeout: int = 0)
| 353 | super().emu_stop() |
| 354 | |
| 355 | def tasks_start(self, count: int = 0, timeout: int = 0): |
| 356 | """ This will start emulation until all tasks get done. |
| 357 | count: Stop after sceduling *count* times. <=0 disables this check. |
| 358 | timeout: Stop after *timeout* ms. <=0 disables this check. |
| 359 | """ |
| 360 | workset = [] # type: List[gevent.Greenlet] |
| 361 | self._to_stop = False |
| 362 | self._count = count |
| 363 | |
| 364 | if self._nested_started != 0: |
| 365 | print("Warning: tasks_start is called inside an uc_emu_start!") |
| 366 | return |
| 367 | |
| 368 | with NestedCounter(self): |
| 369 | |
| 370 | if self._count <= 0: |
| 371 | self._count = 0 |
| 372 | |
| 373 | if self._multitask_enabled: |
| 374 | |
| 375 | if timeout > 0: |
| 376 | workset.append(gevent.spawn(self._timeout_main, timeout)) |
| 377 | |
| 378 | while len(self._tasks) != 0 and not self._to_stop: |
| 379 | |
| 380 | new_workset = [ v for v in workset if not v.dead] |
| 381 | |
| 382 | for utk_id in self._tasks: |
| 383 | new_workset.append(gevent.spawn(self._task_main, utk_id)) |
| 384 | |
| 385 | workset = new_workset |
| 386 | |
| 387 | gevent.joinall(workset, raise_error=True) |
| 388 | |
| 389 | if len(self._tasks) == 0: |
| 390 | self._multitask_enabled = False |
no test coverage detected