Skip to content

Commit

Permalink
data loading: first wait for all, then get for exception handling (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling authored Oct 28, 2024
1 parent c0ab2c3 commit 182d70c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ data::data(std::filesystem::path p, config const& c)
}
});

auto const wait = [](char const* context, auto& future) {
auto const throw_if_failed = [](char const* context, auto& future) {
try {
future.get();
} catch (std::exception const& e) {
Expand All @@ -145,12 +145,19 @@ data::data(std::filesystem::path p, config const& c)
}
};

wait("geocoder", geocoder);
wait("tt", tt);
wait("street_routing", street_routing);
wait("matches", matches);
wait("elevators", elevators);
wait("tiles", tiles);
geocoder.wait();
tt.wait();
street_routing.wait();
matches.wait();
elevators.wait();
tiles.wait();

throw_if_failed("geocoder", geocoder);
throw_if_failed("tt", tt);
throw_if_failed("street_routing", street_routing);
throw_if_failed("matches", matches);
throw_if_failed("elevators", elevators);
throw_if_failed("tiles", tiles);
}

data::~data() = default;
Expand Down

0 comments on commit 182d70c

Please sign in to comment.