LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
SharedResource.h
Go to the documentation of this file.
1 #ifndef art_Utilities_SharedResource_h
2 #define art_Utilities_SharedResource_h
3 
4 #include "hep_concurrency/SerialTaskQueue.h"
5 
6 #include <map>
7 #include <set>
8 #include <string>
9 #include <typeinfo>
10 #include <vector>
11 
12 #include <tbb/task_group.h> // Can't forward-declare this class.
13 
14 namespace art {
15  namespace detail {
17  SharedResource_t(std::string const& name, bool demangle);
19  std::string name;
20  };
21  extern SharedResource_t const LegacyResource;
22  }
23 
24  template <typename T>
26 }
27 
28 // =====================================================================
29 
30 namespace art::detail {
32  public:
34 
35  void registerSharedResources(std::set<std::string> const& names);
36  void registerSharedResource(detail::SharedResource_t const&);
37  void freeze(tbb::task_group& group);
38 
39  using queue_ptr_t = std::shared_ptr<hep::concurrency::SerialTaskQueue>;
40  std::vector<queue_ptr_t> createQueues(
41  std::vector<std::string> const& resourceNames) const;
42 
43  private:
44  void register_resource(std::string const& name);
45  void ensure_not_frozen(std::string const& name);
46 
47  std::map<std::string, unsigned> resourceCounts_;
48  std::vector<std::pair<std::string, queue_ptr_t>> sortedResources_;
49  bool frozen_{false};
50  unsigned nLegacy_{};
51  };
52 }
53 
54 #endif /* art_Utilities_SharedResource_h */
55 
56 // Local Variables:
57 // mode: c++
58 // End:
std::map< std::string, unsigned > resourceCounts_
std::string demangle(T const *=nullptr)
Outputs a demangled name for type T.
Definition: DebugUtils.h:343
std::shared_ptr< hep::concurrency::SerialTaskQueue > queue_ptr_t
std::vector< std::pair< std::string, queue_ptr_t > > sortedResources_
SharedResource_t const LegacyResource
SharedResource_t(std::string const &name, bool demangle)
detail::SharedResource_t SharedResource
Definition: MVAAlg.h:12