LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
ScheduleContext.h
Go to the documentation of this file.
1 #ifndef art_Framework_Services_System_ScheduleContext_h
2 #define art_Framework_Services_System_ScheduleContext_h
3 
6 
7 #include <atomic>
8 
9 namespace art {
10  class ScheduleContext;
11 
12  namespace detail {
13  class ScheduleContextSetter; // Forward declaration for friendship.
14  }
15 }
16 
17 extern int main(); // Forward declaration for friendship of test.
18 
20 public:
21  explicit ScheduleContext() noexcept = default;
22  ScheduleID currentScheduleID() const;
23 
25  friend int ::main();
26 
27 private:
28  bool setContext();
29  bool resetContext();
30 
31  using flag_type = unsigned char;
32  std::atomic<flag_type> in_context_{false};
33 };
34 
35 inline bool
37 {
38  return in_context_.fetch_or(true);
39 }
40 
41 inline bool
43 {
44  return in_context_.fetch_and(false);
45 }
46 
48 #endif /* art_Framework_Services_System_ScheduleContext_h */
49 
50 // Local Variables:
51 // mode: c++
52 // End:
#define DECLARE_ART_SYSTEM_SERVICE(svc, scope)
unsigned char flag_type
int main()
Definition: example_main.cc:17
HLT enums.