about summary refs log tree commit diff stats
path: root/cpp/038scheduler
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-24 19:58:38 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-24 19:58:38 -0700
commitb75e94b317509b26d60223db6cf8f388890a79fb (patch)
tree87ea2d6fbba474b3e1e7312229cc33c0d925ee0e /cpp/038scheduler
parente7eeb47570abdc9c416a7dc4a88febfb380ef98a (diff)
downloadmu-b75e94b317509b26d60223db6cf8f388890a79fb.tar.gz
1169 - use the global variable god gave you
Diffstat (limited to 'cpp/038scheduler')
-rw-r--r--cpp/038scheduler12
1 files changed, 7 insertions, 5 deletions
diff --git a/cpp/038scheduler b/cpp/038scheduler
index 3196795c..5ca6cbdc 100644
--- a/cpp/038scheduler
+++ b/cpp/038scheduler
@@ -8,12 +8,14 @@ size_t Scheduling_interval = 500;
 //: todo: these changes are ugly and brittle
 :(replace{} "void run(recipe_number r)")
 void run(recipe_number r) {
-  run(routine(r), Scheduling_interval);
+  routine rr(r);
+  Current_routine = &rr;
+  run_current_routine(Scheduling_interval);
 }
-:(replace "void run(routine rr)")
-void run(routine rr, size_t time_slice)
-:(replace "while (!done(rr))" following "void run(routine rr, size_t time_slice)")
+:(replace "void run_current_routine()")
+void run_current_routine(size_t time_slice)
+:(replace "while (!done())" following "void run_current_routine(size_t time_slice)")
 size_t ninstrs = 0;
-while (!done(rr) && ninstrs < time_slice)
+while (!done() && ninstrs < time_slice)
 :(after "Running One Instruction")
 ninstrs++;