Skip to content

Commit

Permalink
Make sure to take lock long enough
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jun 11, 2024
1 parent 2c30196 commit 7d2167d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/podio/GenericParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,11 @@ std::vector<std::string> GenericParameters::getKeys() const {
template <typename T, typename>
std::vector<std::vector<T>> GenericParameters::getValues() const {
std::vector<std::vector<T>> values;
const auto& map = getMap<T>();
values.reserve(map.size());

{
auto& mtx = getMutex<T>();
const auto& map = getMap<T>();
std::lock_guard lock{mtx};
values.reserve(map.size());
std::transform(map.begin(), map.end(), std::back_inserter(values), [](const auto& pair) { return pair.second; });
}
return values;
Expand Down

0 comments on commit 7d2167d

Please sign in to comment.