Skip to content

Commit

Permalink
Update k4FWCore/components/UniqueIDGenSvc.cpp
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Madlener <[email protected]>
  • Loading branch information
jmcarcell and tmadlener authored Oct 9, 2024
1 parent 1994069 commit 69248a7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions k4FWCore/components/UniqueIDGenSvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ size_t UniqueIDGenSvc::getUniqueID(uint32_t evt_num, uint32_t run_num, const std
}

auto hash = std::hash<std::bitset<bits64 + bits32 + bits32 + bitsSizeT>>{}(combined_bits);
std::lock_guard<std::mutex> lock(m_mutex);
if (m_uniqueIDs.contains(hash)) {
bool inserted = false;
{
std::lock_guard<std::mutex> lock(m_mutex);
std::tie(std::ignore, inserted), = m_uniqueIDs.insert(hash);
}
if (!inserted) {
warning() << "Event number " << evt_num << ", run number " << run_num << " and algorithm name \"" << name
<< "\" have already been used. Please check the uniqueness of the event number, run number and name."
<< endmsg;
} else {
m_uniqueIDs.insert(hash);
}

return hash;
Expand Down

0 comments on commit 69248a7

Please sign in to comment.