Skip to content

Commit

Permalink
Fix the uniqueness detection in the finalizer even further.
Browse files Browse the repository at this point in the history
  • Loading branch information
timspainNERSC committed Oct 1, 2024
1 parent b0c4d35 commit 8392976
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions core/src/Finalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ bool Finalizer::contains(const FinalFn& fn)
{
auto& fns = functions();
for (const auto& stored : fns) {
// Compare function pointer addresses
if (stored.target<FnType*>() == fn.target<FnType*>())
// Compare function addresses
if (*stored.target<FnType*>() == *fn.target<FnType*>())
return true;
}
return false;
Expand All @@ -37,8 +37,14 @@ bool Finalizer::contains(const FinalFn& fn)
void Finalizer::finalize()
{
while (!functions().empty()) {
// Execute the last function in the list
functions().back()();
try {
// Execute the last function in the list
functions().back()();
} catch (const std::exception& e) {
// Remove the function from the finalization list even if an exception was thrown.
functions().pop_back();
throw;
}
// Remove the function from the finalization list.
functions().pop_back();
}
Expand Down

0 comments on commit 8392976

Please # to comment.