diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-05 17:41:10 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-05 17:41:10 -0700 |
commit | 6d17ef493bbec78ebda37e50e0cc8ce21fd9f46b (patch) | |
tree | a4d02b353ef4a1c8cf9d51ed07838dde06a9b49a /cpp/038scheduler.cc | |
parent | 6673e1fc4527147da453435203434394bbeaa513 (diff) | |
download | mu-6d17ef493bbec78ebda37e50e0cc8ce21fd9f46b.tar.gz |
1266 - 'start-running' returns a unique routine id
Diffstat (limited to 'cpp/038scheduler.cc')
-rw-r--r-- | cpp/038scheduler.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/cpp/038scheduler.cc b/cpp/038scheduler.cc index f750e4a3..dbefe556 100644 --- a/cpp/038scheduler.cc +++ b/cpp/038scheduler.cc @@ -90,6 +90,20 @@ for (index_t i = 0; i < Routines.size(); ++i) delete Routines[i]; Routines.clear(); +//:: To schedule new routines to run, call 'start-scheduling'. + +//: 'start-scheduling' will return a unique id for the routine that was +//: created. +:(before "End routine Fields") +index_t id; +:(before "End Globals") +index_t Next_routine_id = 1; +:(before "End Setup") +Next_routine_id = 1; +:(before "End routine Constructor") +id = Next_routine_id; +Next_routine_id++; + :(before "End Primitive Recipe Declarations") START_RUNNING, :(before "End Primitive Recipe Numbers") @@ -98,7 +112,13 @@ Recipe_number["start-running"] = START_RUNNING; case START_RUNNING: { trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name; assert(!current_instruction().ingredients[0].initialized); - Routines.push_back(new routine(Recipe_number[current_instruction().ingredients[0].name])); + routine* new_routine = new routine(Recipe_number[current_instruction().ingredients[0].name]); + Routines.push_back(new_routine); + if (!current_instruction().products.empty()) { + vector<long long int> result; + result.push_back(new_routine->id); + write_memory(current_instruction().products[0], result); + } break; } @@ -135,6 +155,16 @@ recipe f2 [ +schedule: f1 +run: instruction f1/2 +:(scenario start_running_returns_routine_id) +% Scheduling_interval = 1; +recipe f1 [ + 1:integer <- start-running f2:recipe +] +recipe f2 [ + 12:integer <- copy 44:literal +] ++mem: storing 2 in location 1 + :(scenario scheduler_skips_completed_routines) # this scenario will require some careful setup in escaped C++ # (straining our tangle capabilities to near-breaking point) |