CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OutputModuleBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWCore/Framework
4 // Class : OutputModuleBase
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 //
10 
11 // system include files
12 #include <cassert>
13 
14 // user include files
18 
19 namespace edm {
20  namespace limited {
21 
22  // -------------------------------------------------------
24  : core::OutputModuleCore(pset), queue_(pset.getUntrackedParameter<unsigned int>("concurrencyLimit")) {}
25 
27  auto nstreams = iPC.numberOfStreams();
28 
29  preallocStreams(nstreams);
31  preallocate(iPC);
32  }
33 
35 
37  ActivityRegistry* act,
38  ModuleCallingContext const* mcc) {
39  { core::OutputModuleCore::doEvent_(info, act, mcc); }
40 
41  auto remainingEvents = remainingEvents_.load();
42  bool keepTrying = remainingEvents > 0;
43  while (keepTrying) {
44  auto newValue = remainingEvents - 1;
45  keepTrying = !remainingEvents_.compare_exchange_strong(remainingEvents, newValue);
46  if (keepTrying) {
47  // the exchange failed because the value was changed by another thread.
48  // remainingEvents was changed to be the new value of remainingEvents_;
49  keepTrying = remainingEvents > 0;
50  }
51  }
52  return true;
53  }
54 
56  std::vector<std::string> const& defaultOutputCommands) {
57  core::OutputModuleCore::fillDescription(desc, defaultOutputCommands);
58  desc.addUntracked<unsigned int>("concurrencyLimit", 1);
59  }
60  } // namespace limited
61 } // namespace edm
static const TGPicture * info(bool iBackgroundIsBlack)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void doPreallocate(PreallocationConfiguration const &)
void doPreallocate_(PreallocationConfiguration const &)
OutputModuleBase(ParameterSet const &pset)
std::atomic< int > remainingEvents_
bool doEvent_(EventTransitionInfo const &, ActivityRegistry *, ModuleCallingContext const *)
virtual void preallocate(PreallocationConfiguration const &)
virtual void preallocStreams(unsigned int)
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
bool doEvent(EventTransitionInfo const &, ActivityRegistry *, ModuleCallingContext const *)
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())