1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// -*- C++ -*-
//
// Package: FWCore/Framework
// Class : OutputModuleBase
//
// Implementation:
// [Notes on implementation]
//
//
// system include files
#include <cassert>
// user include files
#include "FWCore/Framework/interface/limited/OutputModuleBase.h"
#include "FWCore/Framework/interface/PreallocationConfiguration.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
namespace edm {
namespace limited {
// -------------------------------------------------------
OutputModuleBase::OutputModuleBase(ParameterSet const& pset)
: core::OutputModuleCore(pset), queue_(pset.getUntrackedParameter<unsigned int>("concurrencyLimit")) {}
void OutputModuleBase::doPreallocate(PreallocationConfiguration const& iPC) {
auto nstreams = iPC.numberOfStreams();
preallocStreams(nstreams);
core::OutputModuleCore::doPreallocate_(iPC);
preallocate(iPC);
}
void OutputModuleBase::doBeginJob() { core::OutputModuleCore::doBeginJob_(); }
bool OutputModuleBase::doEvent(EventTransitionInfo const& info,
ActivityRegistry* act,
ModuleCallingContext const* mcc) {
{ core::OutputModuleCore::doEvent_(info, act, mcc); }
auto remainingEvents = remainingEvents_.load();
bool keepTrying = remainingEvents > 0;
while (keepTrying) {
auto newValue = remainingEvents - 1;
keepTrying = !remainingEvents_.compare_exchange_strong(remainingEvents, newValue);
if (keepTrying) {
// the exchange failed because the value was changed by another thread.
// remainingEvents was changed to be the new value of remainingEvents_;
keepTrying = remainingEvents > 0;
}
}
return true;
}
void OutputModuleBase::fillDescription(ParameterSetDescription& desc,
std::vector<std::string> const& defaultOutputCommands) {
core::OutputModuleCore::fillDescription(desc, defaultOutputCommands);
desc.addUntracked<unsigned int>("concurrencyLimit", 1);
}
} // namespace limited
} // namespace edm
|