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

#include <assert_only_one_thread.h>

Public Member Functions

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

Private Attributes

ThreadCountertc_
 

Detailed Description

Definition at line 38 of file assert_only_one_thread.h.

Constructor & Destructor Documentation

cet::detail::ThreadCounter::Sentry::~Sentry ( )
inlinenoexcept

Definition at line 40 of file assert_only_one_thread.h.

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

Definition at line 41 of file assert_only_one_thread.h.

41  : tc_{tc}
42  {
43  if (++tc_.counter_ == 1u) {
44  return;
45  }
46  std::cerr << "Failed assert--more than one thread accessing location:\n"
47  << " " << tc_.filename_ << ':' << tc_.linenum_ << '\n'
48  << " function: " << tc_.funcname_ << '\n';
49  if (terminate) {
50  std::abort();
51  }
52  }
std::atomic< unsigned > counter_

Member Data Documentation

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

Definition at line 55 of file assert_only_one_thread.h.


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