diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-08-16 11:34:22 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-08-16 11:34:22 -0700 |
commit | be52aad2c2478b83ea672eeb73530f808742f98b (patch) | |
tree | ad9c7d5e0cc22d3440bad5653afc1f7a9be3fa25 | |
parent | 0de5692bb3bf63a961c956a4f10b5db4ce7dbd27 (diff) | |
download | mu-be52aad2c2478b83ea672eeb73530f808742f98b.tar.gz |
3193
Bugfix: 'restart' should never restart completed routines. They will often have nothing to run. I ran into this while considering whether 'read' on channels to return true on success or failure. Switching from 'fail?' to 'success?' crashed. But now that it's fixed I think I'll keep things the way they are. No reason to be consistent with 'next-ingredient' and have the status be true to signal success.
-rw-r--r-- | 073wait.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/073wait.cc b/073wait.cc index 147d442a..78a5c46f 100644 --- a/073wait.cc +++ b/073wait.cc @@ -328,6 +328,8 @@ int some_other_running_routine() { return 0; } +//: helper for restarting blocking routines in tests + :(before "End Primitive Recipe Declarations") RESTART, :(before "End Primitive Recipe Numbers") @@ -349,9 +351,25 @@ case RESTART: { int id = ingredients.at(0).at(0); for (int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->id == id) { - Routines.at(i)->state = RUNNING; + if (Routines.at(i)->state == WAITING) + Routines.at(i)->state = RUNNING; break; } } break; } + +:(scenario cannot_restart_completed_routine) +% Scheduling_interval = 1; +def main [ + local-scope + r:number/routine-id <- start-running f + x:number <- copy 0 # wait for f to be scheduled + # r is COMPLETED by this point + restart r # should have no effect + x:number <- copy 0 # give f time to be scheduled (though it shouldn't be) +] +def f [ + 1:number/raw <- copy 1 +] +# shouldn't crash |