Skip to content

Commit

Permalink
build the dependency graph only after establishing all connections
Browse files Browse the repository at this point in the history
  • Loading branch information
cmnrd committed Oct 10, 2023
1 parent fa685f1 commit 3b25ffe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion include/reactor-cpp/environment.hh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public:

template <class T> void draw_connection(Port<T>* source, Port<T>* sink, ConnectionProperties properties) {
if (top_environment_ == nullptr || top_environment_ == this) {
log::Debug() << "drawing connection: " << source << " --> " << sink;
log::Debug() << "drawing connection: " << source->fqn() << " --> " << sink->fqn();
graph_.add_edge(source, sink, properties);
} else {
top_environment_->draw_connection(source, sink, properties);
Expand Down
31 changes: 16 additions & 15 deletions lib/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@ void Environment::assemble() { // NOLINT
recursive_assemble(reactor);
}

log::Debug() << "start optimization on port graph";
this->optimize();
// this assembles all the contained environments aka enclaves
for (auto* env : contained_environments_) {
env->assemble();
}

log::Debug() << "instantiating port graph declaration";
// If this is the top level environment, then instantiate all connections.
if (top_environment_ == nullptr || top_environment_ == this) {
log::Debug() << "start optimization on port graph";
this->optimize();

log::Debug() << "instantiating port graph declaration";
log::Debug() << "graph: ";
log::Debug() << optimized_graph_;

Expand Down Expand Up @@ -136,18 +142,6 @@ void Environment::assemble() { // NOLINT
}
}
}

log::Debug() << "Building the Dependency-Graph";
for (auto* reactor : top_level_reactors_) {
build_dependency_graph(reactor);
}

calculate_indexes();

// this assembles all the contained environments aka enclaves
for (auto* env : contained_environments_) {
env->assemble();
}
}

void Environment::build_dependency_graph(Reactor* reactor) { // NOLINT
Expand Down Expand Up @@ -326,6 +320,13 @@ auto Environment::startup() -> std::thread {
auto Environment::startup(const TimePoint& start_time) -> std::thread {
validate(this->phase() == Phase::Assembly, "startup() may only be called during assembly phase!");

log::Debug() << "Building the Dependency-Graph";
for (auto* reactor : top_level_reactors_) {
build_dependency_graph(reactor);
}

calculate_indexes();

log_.debug() << "Starting the execution";
phase_ = Phase::Startup;

Expand Down

0 comments on commit 3b25ffe

Please sign in to comment.