Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions Src/Base/AMReX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
#include <stack>
#include <string>
#include <thread>
#include <utility>
#include <limits>
#include <vector>
#include <algorithm>
Expand Down Expand Up @@ -441,13 +442,13 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse,
while ( ! The_Initialize_Function_Stack.empty())
{
//
// Call the registered function.
//
The_Initialize_Function_Stack.top()();
//
// And then remove it from the stack.
// Remove the function from the stack before calling it, so that a function
// that calls ExecOnInitialize itself neither runs twice nor drops the newly
// registered function.
//
auto f = std::move(The_Initialize_Function_Stack.top());
The_Initialize_Function_Stack.pop();
f();
}

BL_PROFILE_INITIALIZE();
Expand Down Expand Up @@ -854,13 +855,13 @@ amrex::Finalize (amrex::AMReX* pamrex)
while (!The_Finalize_Function_Stack.empty())
{
//
// Call the registered function.
//
The_Finalize_Function_Stack.top()();
//
// And then remove it from the stack.
// Remove the function from the stack before calling it, so that a function
// that calls ExecOnFinalize itself neither runs twice nor drops the newly
// registered function.
//
auto f = std::move(The_Finalize_Function_Stack.top());
The_Finalize_Function_Stack.pop();
f();
}

// The MemPool stuff is not using The_Finalize_Function_Stack so that
Expand Down
Loading