Skip to content

Commit

Permalink
Fix serializer lock predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsdukai committed Dec 1, 2024
1 parent 121fdd1 commit ed1c04b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions apps/roofer-app/roofer-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,9 +897,11 @@ int main(int argc, const char* argv[]) {
!reconstructed_buildings.empty()) {
logger.debug("[sorter] before lock reconstructed_buildings_mutex");
std::unique_lock lock{reconstructed_buildings_mutex};
reconstructed_pending.wait(lock, [&reconstructed_buildings] {
return !reconstructed_buildings.empty();
});
reconstructed_pending.wait(
lock, [&reconstructed_buildings, &reconstruction_running] {
return !reconstructed_buildings.empty() ||
!reconstruction_running.load();
});
auto pending_sorted{std::move(reconstructed_buildings)};
reconstructed_buildings.clear();
reconstructed_buildings.shrink_to_fit();
Expand Down Expand Up @@ -963,8 +965,9 @@ int main(int argc, const char* argv[]) {
while (sorting_running.load() || !sorted_tiles.empty()) {
logger.debug("[serializer] before lock sorted_tiles_mutex");
std::unique_lock lock{sorted_tiles_mutex};
sorted_pending.wait(lock,
[&sorted_tiles] { return !sorted_tiles.empty(); });
sorted_pending.wait(lock, [&sorted_tiles, &sorting_running] {
return !sorted_tiles.empty() || !sorting_running.load();
});
auto pending_serialized{std::move(sorted_tiles)};
sorted_tiles.clear();
sorted_tiles.shrink_to_fit();
Expand Down

0 comments on commit ed1c04b

Please sign in to comment.