I have come across #6664 ("Replace TimerOutput::Scope to avoid deadlocks") which replaces the uses of TimerOutput::Scope by explicit calls to timer.enter_subsection() and timer.leave_subsection(). But I am mystified by what that actually solved. At least the current state of TimerOutput::Scope looks as follows:
inline TimerOutput::Scope::Scope(dealii::TimerOutput &timer_,
const std::string §ion_name_)
: timer(timer_)
, section_name(section_name_)
, in(true)
{
timer.enter_subsection(section_name);
}
inline void
TimerOutput::Scope::stop()
{
if (!in)
return;
in = false;
timer.leave_subsection(section_name);
}
TimerOutput::Scope::~Scope()
{
try
{
stop();
}
catch (...)
{}
}
This is not functionally different from manually calling enter/leave_subsection() with the exception of the try-catch clause. On the other hand, the old scheme did not require us to track where we exit a function -- the destructor did the leaving.
Did TimerOutput::Scope change? Or is the presence of the try-catch the problem? How about a replacement class that just doesn't have the try-catch that does what we want in the destructor?
I have come across #6664 ("Replace TimerOutput::Scope to avoid deadlocks") which replaces the uses of
TimerOutput::Scopeby explicit calls totimer.enter_subsection()andtimer.leave_subsection(). But I am mystified by what that actually solved. At least the current state ofTimerOutput::Scopelooks as follows:This is not functionally different from manually calling
enter/leave_subsection()with the exception of thetry-catchclause. On the other hand, the old scheme did not require us to track where we exit a function -- the destructor did the leaving.Did
TimerOutput::Scopechange? Or is the presence of thetry-catchthe problem? How about a replacement class that just doesn't have thetry-catchthat does what we want in the destructor?