From d990e8f07aee36f68bcd270889d20c2d22b9aa0b Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 17 Aug 2016 19:04:35 -0700 Subject: 3219 Trying keeping html in the master branch: https://github.com/blog/2228-simpler-github-pages-publishing Let's see if https://akkartik.github.io/mu updates after I push this commit to just the master branch. --- html/073wait.cc.html | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'html/073wait.cc.html') diff --git a/html/073wait.cc.html b/html/073wait.cc.html index dffb1cf5..49bdd7d3 100644 --- a/html/073wait.cc.html +++ b/html/073wait.cc.html @@ -361,6 +361,52 @@ put(Recipe_ordinal,} return 0; } + +//: helper for restarting blocking routines in tests + +:(before "End Primitive Recipe Declarations") +RESTART, +:(before "End Primitive Recipe Numbers") +put(Recipe_ordinal, "restart", RESTART); +:(before "End Primitive Recipe Checks") +case RESTART: { + if (SIZE(inst.ingredients) != 1) { + raise << maybe(get(Recipe, r).name) << "'restart' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); + break; + } + if (!is_mu_number(inst.ingredients.at(0))) { + raise << maybe(get(Recipe, r).name) << "first ingredient of 'restart' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + break; + } + break; +} +:(before "End Primitive Recipe Implementations") +case RESTART: { + int id = ingredients.at(0).at(0); + for (int i = 0; i < SIZE(Routines); ++i) { + if (Routines.at(i)->id == id) { + 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 -- cgit 1.4.1-2-gfad0