Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
fix wakeup
Browse files Browse the repository at this point in the history
  • Loading branch information
iopapamanoglou committed Nov 14, 2024
1 parent 55f1e39 commit d5aaa78
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/faebryk/core/cpp/include/pathfinder/bfs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class BFSPath : public Path, public std::enable_shared_from_this<BFSPath> {
BFSPath(const BFSPath &other);
BFSPath(const BFSPath &other, /*const*/ GI_ref_weak new_head);
BFSPath(BFSPath &&other) = delete;
BFSPath operator+(/*const*/ GI_ref_weak gif);
std::shared_ptr<BFSPath> operator+(/*const*/ GI_ref_weak gif);

PathData &get_path_data_mut();
PathData &get_path_data() /*const*/;
Expand Down
20 changes: 11 additions & 9 deletions src/faebryk/core/cpp/src/pathfinder/bfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ BFSPath::BFSPath(const BFSPath &other, /*const*/ GI_ref_weak new_head)
assert(!other.filtered);
}

BFSPath BFSPath::operator+(/*const*/ GI_ref_weak gif) {
return BFSPath(*this, gif);
std::shared_ptr<BFSPath> BFSPath::operator+(/*const*/ GI_ref_weak gif) {

return std::make_shared<BFSPath>(*this, gif);
}

PathData &BFSPath::get_path_data_mut() {
Expand Down Expand Up @@ -117,11 +118,12 @@ void bfs_visit(/*const*/ GI_ref_weak root, std::function<void(BFSPath &)> visito

if (path->wake_signal) {
for (auto it = hibernated_paths.begin(); it != hibernated_paths.end();) {
if (!it->get()->hibernated) {
open_path_queue.push_back(std::move(*it));
it = hibernated_paths.erase(it);
} else if (!it->get()->filtered) {
if (!it->get()->filtered) {
hibernated_paths.erase(it);
} else if (!it->get()->hibernated) {
open_path_queue.push_back(*it);
it = hibernated_paths.erase(it);
//
} else {
++it;
}
Expand All @@ -146,9 +148,9 @@ void bfs_visit(/*const*/ GI_ref_weak root, std::function<void(BFSPath &)> visito

pc_deque_insert.resume();
if (path->hibernated) {
hibernated_paths.push_back(std::move(path));
hibernated_paths.push_back(path);
} else {
open_path_queue.push_back(std::move(path));
open_path_queue.push_back(path);
}
pc_deque_insert.pause();
};
Expand Down Expand Up @@ -177,7 +179,7 @@ void bfs_visit(/*const*/ GI_ref_weak root, std::function<void(BFSPath &)> visito
pc_check_visited.pause();

pc_new_path.resume();
auto new_path = std::make_shared<BFSPath>(*path, neighbour);
auto new_path = *path + neighbour;
pc_new_path.pause();
pc_search.pause();
handle_path(new_path);
Expand Down
3 changes: 2 additions & 1 deletion src/faebryk/core/cpp/src/pathfinder/pathfinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,9 @@ bool PathFinder::_handle_valid_split_branch(BFSPath &p) {
// they will check themselves
split_state.waiting = true;
} else {
auto &back = wait_paths.back();
// TODO maybe use queue instead of vector
wait_paths.back()->hibernated = false;
back->hibernated = false;
wait_paths.pop_back();
p.wake_signal = true;
}
Expand Down

0 comments on commit d5aaa78

Please sign in to comment.