Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
art::detail::SharedModule Class Reference

#include <SharedModule.h>

Inheritance diagram for art::detail::SharedModule:
art::detail::LegacyModule art::OutputModule art::ResultsProducer art::SharedAnalyzer art::SharedFilter art::SharedProducer art::EDAnalyzer art::EDFilter art::EDProducer art::FileDumperOutput art::ProvenanceCheckerOutput art::ProvenanceDumper< DETAIL, Enable > art::ProvenanceDumper< DETAIL, std::void_t< typename DETAIL::Config > > art::test::PMTestOutput arttest::EventProcessorTestOutput art::test::DummyResultsProducer art::BlockingPrescaler art::EventIDFilter art::Prescaler simfilter::FilterNoMCParticles simfilter::FilterSimPhotonLiteTime simfilter::FilterSimPhotonTime art::RandomNumberSaver hit::GausHitFinder wcls::WireCellToolkit

Public Member Functions

 SharedModule ()
 
 SharedModule (std::string const &moduleLabel)
 
hep::concurrency::SerialTaskQueueChain * serialTaskQueueChain () const
 
std::set< std::string > const & sharedResources () const
 
void createQueues (SharedResources const &resources)
 
template<BranchType , typename... T>
void serialize (T const &...resources)
 
template<BranchType , typename... T>
void serializeExternal (T const &...resources)
 

Protected Member Functions

template<BranchType BT = InEvent, typename... T>
void serialize (T const &...)
 
template<BranchType BT = InEvent, typename... T>
void serializeExternal (T const &...)
 
template<BranchType BT = InEvent>
void async ()
 

Private Member Functions

void implicit_serialize ()
 
void serialize_for (std::string const &name)
 
template<typename... T>
void serialize_for_resource (T const &...t)
 
template<typename... T>
void serialize_for_external_resource (T const &...t)
 

Private Attributes

std::string moduleLabel_
 
std::set< std::stringresourceNames_ {}
 
bool asyncDeclared_ {false}
 
std::unique_ptr< hep::concurrency::SerialTaskQueueChain > chain_ {nullptr}
 

Detailed Description

Definition at line 17 of file SharedModule.h.

Constructor & Destructor Documentation

art::detail::SharedModule::SharedModule ( )

Definition at line 15 of file SharedModule.cc.

15 : SharedModule{""s} {}
static QCString * s
Definition: config.cpp:1042
art::detail::SharedModule::SharedModule ( std::string const &  moduleLabel)
explicit

Definition at line 17 of file SharedModule.cc.

18  : moduleLabel_{moduleLabel}
19  {}

Member Function Documentation

template<BranchType BT = InEvent>
void art::detail::SharedModule::async ( )
inlineprotected

Definition at line 36 of file SharedModule.h.

37  {
38  static_assert(
39  BT == InEvent,
40  "async is currently supported only for the 'InEvent' level.");
41  asyncDeclared_ = true;
42  }
void art::detail::SharedModule::createQueues ( SharedResources const &  resources)

Definition at line 34 of file SharedModule.cc.

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  }
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
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
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
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
void art::detail::SharedModule::implicit_serialize ( )
private

Definition at line 60 of file SharedModule.cc.

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  }
void serialize_for(std::string const &name)
Definition: SharedModule.cc:72
template<BranchType BT = InEvent, typename... T>
void art::detail::SharedModule::serialize ( T const &  ...)
protected
template<BranchType , typename... T>
void art::detail::SharedModule::serialize ( T const &...  resources)

Definition at line 81 of file SharedModule.h.

82  {
83  serialize_for_resource(resources...);
84  }
void serialize_for_resource(T const &...t)
Definition: SharedModule.h:50
void art::detail::SharedModule::serialize_for ( std::string const &  name)
private

Definition at line 72 of file SharedModule.cc.

73  {
74  resourceNames_.emplace(resourceName);
75  }
std::set< std::string > resourceNames_
Definition: SharedModule.h:74
template<typename... T>
void art::detail::SharedModule::serialize_for_external_resource ( T const &...  t)
inlineprivate

Definition at line 63 of file SharedModule.h.

64  {
65  static_assert(std::conjunction_v<std::is_same<std::string, T>...>);
66  if (sizeof...(t) == 0) {
68  } else {
69  (serialize_for(t), ...);
70  }
71  }
void serialize_for(std::string const &name)
Definition: SharedModule.cc:72
template<typename... T>
void art::detail::SharedModule::serialize_for_resource ( T const &...  t)
inlineprivate

Definition at line 50 of file SharedModule.h.

51  {
52  static_assert(
53  std::conjunction_v<std::is_same<detail::SharedResource_t, T>...>);
54  if (sizeof...(t) == 0) {
56  } else {
57  (serialize_for(t.name), ...);
58  }
59  }
void serialize_for(std::string const &name)
Definition: SharedModule.cc:72
template<BranchType BT = InEvent, typename... T>
void art::detail::SharedModule::serializeExternal ( T const &  ...)
protected
template<BranchType , typename... T>
void art::detail::SharedModule::serializeExternal ( T const &...  resources)

Definition at line 88 of file SharedModule.h.

89  {
90  serialize_for_external_resource(resources...);
91  }
void serialize_for_external_resource(T const &...t)
Definition: SharedModule.h:63
SerialTaskQueueChain * art::detail::SharedModule::serialTaskQueueChain ( ) const

Definition at line 22 of file SharedModule.cc.

23  {
24  return chain_.get();
25  }
std::unique_ptr< hep::concurrency::SerialTaskQueueChain > chain_
Definition: SharedModule.h:76
std::set< std::string > const & art::detail::SharedModule::sharedResources ( ) const

Definition at line 28 of file SharedModule.cc.

29  {
30  return resourceNames_;
31  }
std::set< std::string > resourceNames_
Definition: SharedModule.h:74

Member Data Documentation

bool art::detail::SharedModule::asyncDeclared_ {false}
private

Definition at line 75 of file SharedModule.h.

std::unique_ptr<hep::concurrency::SerialTaskQueueChain> art::detail::SharedModule::chain_ {nullptr}
private

Definition at line 76 of file SharedModule.h.

std::string art::detail::SharedModule::moduleLabel_
private

Definition at line 73 of file SharedModule.h.

std::set<std::string> art::detail::SharedModule::resourceNames_ {}
private

Definition at line 74 of file SharedModule.h.


The documentation for this class was generated from the following files: