SharedModule.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
6 
7 #include <string>
8 #include <vector>
9 
10 using namespace std::string_literals;
11 using namespace hep::concurrency;
12 
13 namespace art::detail {
14 
15  SharedModule::SharedModule() : SharedModule{""s} {}
16 
18  : moduleLabel_{moduleLabel}
19  {}
20 
21  SerialTaskQueueChain*
23  {
24  return chain_.get();
25  }
26 
27  std::set<std::string> const&
29  {
30  return resourceNames_;
31  }
32 
33  void
35  {
37  "An error occurred while processing scheduling options for a "
38  "module.\n"};
39  if (asyncDeclared_) {
40  if (empty(resourceNames_)) {
41  return;
42  }
43  throw e
44  << "async<art::InEvent>() cannot be called in combination with any "
45  "serialize<art::InEvent>(...) calls.\n";
46  }
47 
48  if (empty(resourceNames_)) {
49  throw e << "Either 'async<art::InEvent>()' or "
50  "'serialize<art::InEvent>(...)'\n"
51  "must be called in a shared module's constructor.\n";
52  }
53  std::vector<std::string> const names(cbegin(resourceNames_),
55  auto queues = resources.createQueues(names);
56  chain_ = std::make_unique<SerialTaskQueueChain>(queues);
57  }
58 
59  void
61  {
62  // This is the situation where a shared module must be serialized,
63  // but only wrt. itself--i.e. only one event call at a time.
64  // Because the shared-resources registry is not prepopulated with
65  // module names, we call the 'serialize_for_external' function to
66  // insert an entry into the registry. This is safe to do as only
67  // this module will refer to the shared resource.
69  }
70 
71  void
73  {
74  resourceNames_.emplace(resourceName);
75  }
76 }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
std::set< std::string > resourceNames_
Definition: SharedModule.h:74
std::string string
Definition: nybbler.cc:12
void serialize_for(std::string const &name)
Definition: SharedModule.cc:72
std::set< std::string > const & sharedResources() const
Definition: SharedModule.cc:28
const double e
std::unique_ptr< hep::concurrency::SerialTaskQueueChain > chain_
Definition: SharedModule.h:76
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void createQueues(SharedResources const &resources)
Definition: SharedModule.cc:34
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
Definition: StdUtils.h:82
static std::vector< std::string > const names
Definition: FragmentType.hh:8
hep::concurrency::SerialTaskQueueChain * serialTaskQueueChain() const
Definition: SharedModule.cc:22
std::vector< queue_ptr_t > createQueues(std::vector< std::string > const &resourceNames) const
static QCString * s
Definition: config.cpp:1042
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97