LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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::BlockingPrescaler art::EventIDFilter art::Prescaler simfilter::FilterNoMCParticles simfilter::FilterSimPhotonLiteTime simfilter::FilterSimPhotonTime art::RandomNumberSaver hit::GausHitFinder wcls::WireCellToolkit

Public Member Functions

 SharedModule ()
 
 ~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::string > resourceNames_ {}
 
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 ( )
default
art::detail::SharedModule::~SharedModule ( )
default
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 38 of file SharedModule.h.

References asyncDeclared_, implicit_serialize(), art::InEvent, and serialize_for().

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

Definition at line 34 of file SharedModule.cc.

References asyncDeclared_, util::cbegin(), util::cend(), chain_, art::detail::SharedResources::createQueues(), e, util::empty(), art::errors::LogicError, and resourceNames_.

Referenced by art::OutputModule::doBeginJob(), art::SharedFilter::setupQueues(), art::SharedProducer::setupQueues(), art::EDFilter::setupQueues(), art::SharedAnalyzer::setupQueues(), art::EDProducer::setupQueues(), and art::EDAnalyzer::setupQueues().

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:93
std::set< std::string > resourceNames_
Definition: SharedModule.h:76
std::unique_ptr< hep::concurrency::SerialTaskQueueChain > chain_
Definition: SharedModule.h:78
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:85
Float_t e
Definition: plot.C:35
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109
void art::detail::SharedModule::implicit_serialize ( )
private

Definition at line 60 of file SharedModule.cc.

References moduleLabel_, and serialize_for().

Referenced by async(), serialize_for_external_resource(), and serialize_for_resource().

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 83 of file SharedModule.h.

References serialize_for_resource().

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

Definition at line 72 of file SharedModule.cc.

References resourceNames_.

Referenced by async(), implicit_serialize(), serialize_for_external_resource(), and serialize_for_resource().

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

Definition at line 65 of file SharedModule.h.

References implicit_serialize(), and serialize_for().

Referenced by serializeExternal().

66  {
67  static_assert(std::conjunction_v<std::is_same<std::string, T>...>);
68  if (sizeof...(t) == 0) {
70  } else {
71  (serialize_for(t), ...);
72  }
73  }
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 52 of file SharedModule.h.

References implicit_serialize(), and serialize_for().

Referenced by serialize().

53  {
54  static_assert(
55  std::conjunction_v<std::is_same<detail::SharedResource_t, T>...>);
56  if (sizeof...(t) == 0) {
58  } else {
59  (serialize_for(t.name), ...);
60  }
61  }
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 90 of file SharedModule.h.

References serialize_for_external_resource().

91  {
92  serialize_for_external_resource(resources...);
93  }
void serialize_for_external_resource(T const &...t)
Definition: SharedModule.h:65
SerialTaskQueueChain * art::detail::SharedModule::serialTaskQueueChain ( ) const

Definition at line 22 of file SharedModule.cc.

References chain_.

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

Definition at line 28 of file SharedModule.cc.

References resourceNames_.

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

Member Data Documentation

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

Definition at line 77 of file SharedModule.h.

Referenced by async(), and createQueues().

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

Definition at line 78 of file SharedModule.h.

Referenced by createQueues(), and serialTaskQueueChain().

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

Definition at line 75 of file SharedModule.h.

Referenced by implicit_serialize().

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

Definition at line 76 of file SharedModule.h.

Referenced by createQueues(), serialize_for(), and sharedResources().


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