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 {
19  };
20  extern SharedResource_t const LegacyResource;
21  }
22 
23  template <typename T>
25 }
26 
27 // =====================================================================
28 
29 namespace art::detail {
31  public:
33 
34  void registerSharedResources(std::set<std::string> const& names);
35  void registerSharedResource(detail::SharedResource_t const&);
36  void freeze(tbb::task_group& group);
37 
38  using queue_ptr_t = std::shared_ptr<hep::concurrency::SerialTaskQueue>;
39  std::vector<queue_ptr_t> createQueues(
40  std::vector<std::string> const& resourceNames) const;
41 
42  private:
43  void register_resource(std::string const& name);
44  void ensure_not_frozen(std::string const& name);
45 
46  std::map<std::string, unsigned> resourceCounts_;
47  std::vector<std::pair<std::string, queue_ptr_t>> sortedResources_;
48  bool frozen_{false};
49  unsigned nLegacy_{};
50  };
51 }
52 
53 #endif /* art_Utilities_SharedResource_h */
54 
55 // Local Variables:
56 // mode: c++
57 // End:
std::map< std::string, unsigned > resourceCounts_
std::string demangle(T const *=nullptr)
Outputs a demangled name for type T.
Definition: DebugUtils.h:56
std::string string
Definition: nybbler.cc:12
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
static std::vector< std::string > const names
Definition: FragmentType.hh:8