From d5aaa785bbdf73152cd4b765e383893b936ee15e Mon Sep 17 00:00:00 2001 From: iopapamanoglou Date: Thu, 14 Nov 2024 21:41:21 +0100 Subject: [PATCH] fix wakeup --- .../core/cpp/include/pathfinder/bfs.hpp | 2 +- src/faebryk/core/cpp/src/pathfinder/bfs.cpp | 20 ++++++++++--------- .../core/cpp/src/pathfinder/pathfinder.cpp | 3 ++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/faebryk/core/cpp/include/pathfinder/bfs.hpp b/src/faebryk/core/cpp/include/pathfinder/bfs.hpp index 7e1c6794..c879541a 100644 --- a/src/faebryk/core/cpp/include/pathfinder/bfs.hpp +++ b/src/faebryk/core/cpp/include/pathfinder/bfs.hpp @@ -99,7 +99,7 @@ class BFSPath : public Path, public std::enable_shared_from_this { 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 operator+(/*const*/ GI_ref_weak gif); PathData &get_path_data_mut(); PathData &get_path_data() /*const*/; diff --git a/src/faebryk/core/cpp/src/pathfinder/bfs.cpp b/src/faebryk/core/cpp/src/pathfinder/bfs.cpp index 80bdd55f..b6383d1e 100644 --- a/src/faebryk/core/cpp/src/pathfinder/bfs.cpp +++ b/src/faebryk/core/cpp/src/pathfinder/bfs.cpp @@ -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::operator+(/*const*/ GI_ref_weak gif) { + + return std::make_shared(*this, gif); } PathData &BFSPath::get_path_data_mut() { @@ -117,11 +118,12 @@ void bfs_visit(/*const*/ GI_ref_weak root, std::function 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; } @@ -146,9 +148,9 @@ void bfs_visit(/*const*/ GI_ref_weak root, std::function 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(); }; @@ -177,7 +179,7 @@ void bfs_visit(/*const*/ GI_ref_weak root, std::function visito pc_check_visited.pause(); pc_new_path.resume(); - auto new_path = std::make_shared(*path, neighbour); + auto new_path = *path + neighbour; pc_new_path.pause(); pc_search.pause(); handle_path(new_path); diff --git a/src/faebryk/core/cpp/src/pathfinder/pathfinder.cpp b/src/faebryk/core/cpp/src/pathfinder/pathfinder.cpp index a00cebf8..9923f375 100644 --- a/src/faebryk/core/cpp/src/pathfinder/pathfinder.cpp +++ b/src/faebryk/core/cpp/src/pathfinder/pathfinder.cpp @@ -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; }