InputSourceMutex.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
4 #include "hep_concurrency/RecursiveMutex.h"
5 #include "hep_concurrency/tsan.h"
6 
7 using namespace std;
8 using namespace hep::concurrency;
9 
10 namespace art {
11  RecursiveMutex* InputSourceMutexSentry::inputSourceMutex_{
12  new RecursiveMutex{"art::inputSourceMutex_"}};
13 
14  RecursiveMutex*
16  {
17  static mutex guard_mutex;
18  lock_guard sentry{guard_mutex};
19  inputSourceMutex_ = new RecursiveMutex{"art::inputSourceMutex_"};
20  return inputSourceMutex_;
21  }
22 
23  void
24  InputSourceMutexSentry::shutdown()
25  {
26  ANNOTATE_THREAD_IGNORE_BEGIN;
27  delete inputSourceMutex_;
28  inputSourceMutex_ = nullptr;
29  ANNOTATE_THREAD_IGNORE_END;
30  }
31 
33  public:
34  AutoInputSourceMutexSentryShutdown() noexcept = default;
36  {
37  InputSourceMutexSentry::shutdown();
38  }
40  AutoInputSourceMutexSentryShutdown const&) = delete;
42  delete;
44  AutoInputSourceMutexSentryShutdown const&) = delete;
47  };
48 
49  // The inputSourceMutex_ will be destroyed at global destruction
50  // time if it has not yet been cleanedup. This is to guard against
51  // libraries that do not follow the rules.
53 
54  InputSourceMutexSentry::~InputSourceMutexSentry() noexcept = default;
55 
57  : sentry_{(inputSourceMutex_ == nullptr) ? *startup() : *inputSourceMutex_,
58  __func__}
59  {}
60 
61 } // namespace art
STL namespace.
AutoInputSourceMutexSentryShutdown autoInputSourceMutexSentryShutdown
bool startup
Parse arguments #.