Public Member Functions | Private Attributes | List of all members
cet::detail::ThreadCounter::Sentry Class Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/cetlib/v3_06_01/source/cetlib/assert_only_one_thread.h"

Public Member Functions

 Sentry (ThreadCounter &tc, bool const terminate=true)
 
 ~Sentry () noexcept
 

Private Attributes

ThreadCountertc_
 
bool const terminate_
 
std::mutex m_ {}
 

Detailed Description

Definition at line 46 of file assert_only_one_thread.h.

Constructor & Destructor Documentation

cet::detail::ThreadCounter::Sentry::Sentry ( ThreadCounter tc,
bool const  terminate = true 
)
inline

Definition at line 48 of file assert_only_one_thread.h.

References om::cerr, and submit_hadd::u.

49  : tc_{tc}, terminate_{terminate}
50  {
51  if (++tc_.counter_ != 1u) {
52  // Do not guard the abort!
53  {
54  std::lock_guard<decltype(m_)> hold{m_};
55  std::cerr
56  << "Failed assert--more than one thread accessing location:\n"
57  << " " << tc_.filename_ << ':' << tc_.linenum_ << '\n'
58  << " function: " << tc_.funcname_ << '\n';
59  }
60  if (terminate_) {
61  std::abort();
62  }
63  }
64  }
OStream cerr
Definition: OStream.cxx:7
std::atomic< unsigned > counter_
cet::detail::ThreadCounter::Sentry::~Sentry ( )
inlinenoexcept

Definition at line 66 of file assert_only_one_thread.h.

Member Data Documentation

std::mutex cet::detail::ThreadCounter::Sentry::m_ {}
private

Definition at line 71 of file assert_only_one_thread.h.

ThreadCounter& cet::detail::ThreadCounter::Sentry::tc_
private

Definition at line 69 of file assert_only_one_thread.h.

bool const cet::detail::ThreadCounter::Sentry::terminate_
private

Definition at line 70 of file assert_only_one_thread.h.


The documentation for this class was generated from the following file: