Skip to content

Commit 3b25ffe

Browse files
committed
build the dependency graph only after establishing all connections
1 parent fa685f1 commit 3b25ffe

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

include/reactor-cpp/environment.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public:
8888

8989
template <class T> void draw_connection(Port<T>* source, Port<T>* sink, ConnectionProperties properties) {
9090
if (top_environment_ == nullptr || top_environment_ == this) {
91-
log::Debug() << "drawing connection: " << source << " --> " << sink;
91+
log::Debug() << "drawing connection: " << source->fqn() << " --> " << sink->fqn();
9292
graph_.add_edge(source, sink, properties);
9393
} else {
9494
top_environment_->draw_connection(source, sink, properties);

lib/environment.cc

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

153147
void Environment::build_dependency_graph(Reactor* reactor) { // NOLINT
@@ -326,6 +320,13 @@ auto Environment::startup() -> std::thread {
326320
auto 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

Comments
 (0)