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

Commit

Permalink
Fix logical falicy in use_count refactor and add comments on it being…
Browse files Browse the repository at this point in the history
… a little imperfect
  • Loading branch information
mawildoer committed Nov 12, 2024
1 parent 35b2308 commit a645802
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/faebryk/core/cpp/src/pathfinder/bfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ BFSPath BFSPath::operator+(/*const*/ GI_ref_weak gif) {
}

PathData &BFSPath::get_path_data_mut() {
if (!path_data.use_count() == 1) {
// TODO: this isn't a perfect representation of `unique`
// See: https://en.cppreference.com/w/cpp/memory/shared_ptr/unique
// Unique is removed in C++20, so this is the best we can do for now
// It also comes with issues when multithreading
// See: https://en.cppreference.com/w/cpp/memory/shared_ptr/use_count
if (path_data.use_count() != 1) {
PathData new_data = *path_data;
path_data = std::make_shared<PathData>(new_data);
}
Expand Down

0 comments on commit a645802

Please sign in to comment.