Skip to content

Go back to TimerOutput::Scope? #6897

@bangerth

Description

@bangerth

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   &section_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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions