@@ -85,11 +85,17 @@ void Environment::assemble() { // NOLINT
8585 recursive_assemble (reactor);
8686 }
8787
88- log::Debug () << " start optimization on port graph" ;
89- this ->optimize ();
88+ // this assembles all the contained environments aka enclaves
89+ for (auto * env : contained_environments_) {
90+ env->assemble ();
91+ }
9092
91- log::Debug () << " instantiating port graph declaration " ;
93+ // If this is the top level environment, then instantiate all connections.
9294 if (top_environment_ == nullptr || top_environment_ == this ) {
95+ log::Debug () << " start optimization on port graph" ;
96+ this ->optimize ();
97+
98+ log::Debug () << " instantiating port graph declaration" ;
9399 log::Debug () << " graph: " ;
94100 log::Debug () << optimized_graph_;
95101
@@ -136,18 +142,6 @@ void Environment::assemble() { // NOLINT
136142 }
137143 }
138144 }
139-
140- log::Debug () << " Building the Dependency-Graph" ;
141- for (auto * reactor : top_level_reactors_) {
142- build_dependency_graph (reactor);
143- }
144-
145- calculate_indexes ();
146-
147- // this assembles all the contained environments aka enclaves
148- for (auto * env : contained_environments_) {
149- env->assemble ();
150- }
151145}
152146
153147void Environment::build_dependency_graph (Reactor* reactor) { // NOLINT
@@ -326,6 +320,13 @@ auto Environment::startup() -> std::thread {
326320auto Environment::startup (const TimePoint& start_time) -> std::thread {
327321 validate (this ->phase () == Phase::Assembly, " startup() may only be called during assembly phase!" );
328322
323+ log::Debug () << " Building the Dependency-Graph" ;
324+ for (auto * reactor : top_level_reactors_) {
325+ build_dependency_graph (reactor);
326+ }
327+
328+ calculate_indexes ();
329+
329330 log_.debug () << " Starting the execution" ;
330331 phase_ = Phase::Startup;
331332
0 commit comments