@@ -501,14 +501,6 @@ namespace verona::interpreter
501501 rt::core::behavior_ptr behavior_)
502502 : ui(ui_), behavior(behavior_)
503503 {
504- // FIXME: Oh no, we need to set the local region before running this but
505- // the interpreter would then need to know about behaviors right?
506- // Maybe not? What if the scheduler sets the behavior before doing this?
507- // That could work, I don't like it but it could
508- //
509- // Looking at this, I believe it would be better to let the interpreter
510- // know about behaviors
511-
512504 // There is a question where the active behavior should be set.
513505 //
514506 // Python mixes the runtime and interpreter a bit more. There the runtime
@@ -631,6 +623,21 @@ namespace verona::interpreter
631623 rt::post_run (initial, ui);
632624 }
633625
626+ Scheduler::Scheduler ()
627+ {
628+ auto ui = rt::ui::globalUI ();
629+ assert (ui->is_mermaid ());
630+ reinterpret_cast <rt::ui::MermaidUI*>(ui)->scheduler_ready_list =
631+ &this ->ready ;
632+ }
633+
634+ Scheduler::~Scheduler ()
635+ {
636+ auto ui = rt::ui::globalUI ();
637+ assert (ui->is_mermaid ());
638+ reinterpret_cast <rt::ui::MermaidUI*>(ui)->scheduler_ready_list = nullptr ;
639+ }
640+
634641 void Scheduler::add (rt::core::behavior_ptr behavior)
635642 {
636643 assert (behavior->status == rt::core::Behavior::Status::New);
@@ -751,10 +758,13 @@ namespace verona::interpreter
751758 this ->next_schedule_msg .reset ();
752759 }
753760
761+ // FIXME: We should really get wrid of the UI* abstraction. There is no way
762+ // that we'll ever change the output at this point and it just makes several
763+ // things harder, like this:
754764 auto ui = rt::ui::globalUI ();
755765 assert (ui->is_mermaid ());
756766 auto mermaid = reinterpret_cast <rt::ui::MermaidUI*>(ui);
757- mermaid->draw_schedule ( this -> ready , message);
767+ mermaid->output ( message);
758768 mermaid->close_file ();
759769 }
760770
0 commit comments