Skip to content

Commit 9f94d72

Browse files
committed
add a StreamID to the Pre/PostSource signals, and rename them to Pre/PostSourceEvent
- modify the EventSourceProxy to pass the StreamID to the Pre/PostSource signals - rename the signals to Pre/PostSourceEvent (to be consistent with Pre/PostModuleEvent, etc.) - adapt all services to the change in the signals
1 parent 8436839 commit 9f94d72

File tree

27 files changed

+115
-92
lines changed

27 files changed

+115
-92
lines changed

DQMServices/Core/src/DQMService.cc

+10-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ static void
3434
restrictDQMAccessM(const edm::ModuleDescription &)
3535
{ restrictDQMAccess(); }
3636

37+
static void
38+
restrictDQMAccessS(edm::StreamID)
39+
{ restrictDQMAccess(); }
40+
3741
/// Release access to the DQM core.
3842
static void
3943
releaseDQMAccess(void)
@@ -43,6 +47,10 @@ static void
4347
releaseDQMAccessM(const edm::ModuleDescription &)
4448
{ releaseDQMAccess(); }
4549

50+
static void
51+
releaseDQMAccessS(edm::StreamID)
52+
{ releaseDQMAccess(); }
53+
4654
// -------------------------------------------------------------------
4755
DQMService::DQMService(const edm::ParameterSet &pset, edm::ActivityRegistry &ar)
4856
: store_(&*edm::Service<DQMStore>()),
@@ -53,8 +61,8 @@ DQMService::DQMService(const edm::ParameterSet &pset, edm::ActivityRegistry &ar)
5361
{
5462
ar.watchPreSourceConstruction(&restrictDQMAccessM);
5563
ar.watchPostSourceConstruction(&releaseDQMAccessM);
56-
ar.watchPreSource(&restrictDQMAccess);
57-
ar.watchPostSource(&releaseDQMAccess);
64+
ar.watchPreSourceEvent(&restrictDQMAccessS);
65+
ar.watchPostSourceEvent(&releaseDQMAccessS);
5866
ar.watchPreModule(&restrictDQMAccessM);
5967
ar.watchPostModule(&releaseDQMAccessM);
6068
ar.watchPostProcessEvent(this, &DQMService::flush);

DataFormats/GeometrySurface/plugins/BlockWipedAllocatorService.cc

-6
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class BlockWipedAllocatorService {
5050

5151
blockWipedPool(&pool);
5252
if (m_useAlloc) BlockWipedPoolAllocated::usePool();
53-
iAR.watchPreSource(this,&BlockWipedAllocatorService::preSource);
5453
iAR.watchPreProcessEvent(this,&BlockWipedAllocatorService::preEventProcessing);
5554
iAR.watchPostEndJob(this,&BlockWipedAllocatorService::postEndJob);
5655
iAR.watchPreModule(this,&BlockWipedAllocatorService::preModule);
@@ -60,11 +59,6 @@ class BlockWipedAllocatorService {
6059
// wipe the workspace before each event
6160
void preEventProcessing(const edm::EventID&, const edm::Timestamp&) { wiper();}
6261

63-
// nope event-principal deleted in source
64-
void preSource() {
65-
// wiper();
66-
}
67-
6862
void dump() {
6963
if (m_silent) return;
7064
std::cout << "ReferenceCounted stat"<< std::endl;

EventFilter/Utilities/interface/MicroStateServiceClassic.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ namespace evf{
3737
void preEventProcessing(const edm::EventID&, const edm::Timestamp&);
3838
void postEventProcessing(const edm::Event&, const edm::EventSetup&);
3939

40-
void preSource();
41-
void postSource();
42-
40+
void preSourceEvent(edm::StreamID);
41+
void postSourceEvent(edm::StreamID);
4342

4443
void preModule(const edm::ModuleDescription&);
4544
void postModule(const edm::ModuleDescription&);

EventFilter/Utilities/plugins/FastMonitoringService.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ namespace evf{
4444
reg.watchPreProcessPath(this,&FastMonitoringService::preProcessPath);
4545
reg.watchPreProcessEvent(this,&FastMonitoringService::preEventProcessing);
4646
reg.watchPostProcessEvent(this,&FastMonitoringService::postEventProcessing);
47-
reg.watchPreSource(this,&FastMonitoringService::preSource);
48-
reg.watchPostSource(this,&FastMonitoringService::postSource);
47+
reg.watchPreSourceEvent(this,&FastMonitoringService::preSourceEvent);
48+
reg.watchPostSourceEvent(this,&FastMonitoringService::postSourceEvent);
4949

5050
reg.watchPreModule(this,&FastMonitoringService::preModule);
5151
reg.watchPostModule(this,&FastMonitoringService::postModule);
@@ -246,13 +246,14 @@ namespace evf{
246246
fmt_.m_data.processedJ_.value()++;
247247
fmt_.monlock_.unlock();
248248
}
249-
void FastMonitoringService::preSource()
249+
250+
void FastMonitoringService::preSourceEvent(edm::StreamID)
250251
{
251252
// boost::mutex::scoped_lock sl(lock_);
252253
fmt_.m_data.microstate_ = &reservedMicroStateNames[mIdle];
253254
}
254255

255-
void FastMonitoringService::postSource()
256+
void FastMonitoringService::postSourceEvent(edm::StreamID)
256257
{
257258
// boost::mutex::scoped_lock sl(lock_);
258259
fmt_.m_data.microstate_ = &reservedMicroStateNames[mFwkOvh];

EventFilter/Utilities/plugins/FastMonitoringService.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ namespace evf{
118118
void preEventProcessing(const edm::EventID&, const edm::Timestamp&);
119119
void postEventProcessing(const edm::Event&, const edm::EventSetup&);
120120

121-
void preSource();
122-
void postSource();
121+
void preSourceEvent(edm::StreamID);
122+
void postSourceEvent(edm::StreamID);
123123

124124
void preModule(const edm::ModuleDescription&);
125125
void postModule(const edm::ModuleDescription&);

EventFilter/Utilities/src/MicroStateServiceClassic.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace evf{
1515

1616
reg.watchPreProcessEvent(this,&MicroStateServiceClassic::preEventProcessing);
1717
reg.watchPostProcessEvent(this,&MicroStateServiceClassic::postEventProcessing);
18-
reg.watchPreSource(this,&MicroStateServiceClassic::preSource);
19-
reg.watchPostSource(this,&MicroStateServiceClassic::postSource);
18+
reg.watchPreSourceEvent(this,&MicroStateServiceClassic::preSourceEvent);
19+
reg.watchPostSourceEvent(this,&MicroStateServiceClassic::postSourceEvent);
2020

2121
reg.watchPreModule(this,&MicroStateServiceClassic::preModule);
2222
reg.watchPostModule(this,&MicroStateServiceClassic::postModule);
@@ -53,13 +53,14 @@ namespace evf{
5353
boost::mutex::scoped_lock sl(lock_);
5454
microstate2_ = &input;
5555
}
56-
void MicroStateServiceClassic::preSource()
56+
57+
void MicroStateServiceClassic::preSourceEvent(edm::StreamID)
5758
{
5859
boost::mutex::scoped_lock sl(lock_);
5960
microstate2_ = &input;
6061
}
6162

62-
void MicroStateServiceClassic::postSource()
63+
void MicroStateServiceClassic::postSourceEvent(edm::StreamID)
6364
{
6465
boost::mutex::scoped_lock sl(lock_);
6566
microstate2_ = &fwkovh;

FWCore/Framework/interface/InputSource.h

+11-5
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ namespace edm {
109109
ItemType nextItemType();
110110

111111
/// Read next event
112-
void readEvent(EventPrincipal& ep, StreamContext *);
112+
void readEvent(EventPrincipal& ep, StreamContext &);
113113

114114
/// Read a specific event
115-
bool readEvent(EventPrincipal& ep, EventID const&, StreamContext *);
115+
bool readEvent(EventPrincipal& ep, EventID const&, StreamContext &);
116116

117117
/// Read next luminosity block Auxilary
118118
boost::shared_ptr<LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary();
@@ -279,9 +279,15 @@ namespace edm {
279279

280280
class EventSourceSentry {
281281
public:
282-
explicit EventSourceSentry(InputSource const& source);
282+
EventSourceSentry(InputSource const& source, StreamContext & sc);
283+
~EventSourceSentry();
284+
285+
EventSourceSentry(EventSourceSentry const&) = delete; // Disallow copying and moving
286+
EventSourceSentry& operator=(EventSourceSentry const&) = delete; // Disallow copying and moving
287+
283288
private:
284-
SourceSentry sentry_;
289+
InputSource const& source_;
290+
StreamContext & sc_;
285291
};
286292

287293
class LumiSourceSentry {
@@ -386,7 +392,7 @@ namespace edm {
386392
virtual void readRun_(RunPrincipal& runPrincipal);
387393
virtual void readLuminosityBlock_(LuminosityBlockPrincipal& lumiPrincipal);
388394
virtual void readEvent_(EventPrincipal& eventPrincipal) = 0;
389-
virtual bool readIt(EventID const&, EventPrincipal& eventPrincipal);
395+
virtual bool readIt(EventID const& id, EventPrincipal& eventPrincipal, StreamContext& streamContext);
390396
virtual std::unique_ptr<FileBlock> readFile_();
391397
virtual void closeFile_() {}
392398
virtual bool goToEvent_(EventID const& eventID);

FWCore/Framework/src/EventProcessor.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ namespace edm {
18091809
//TODO this will have to become per stream
18101810
auto& event = principalCache_.eventPrincipal(iStreamIndex);
18111811
StreamContext streamContext(event.streamID(), &processContext_);
1812-
input_->readEvent(event, &streamContext);
1812+
input_->readEvent(event, streamContext);
18131813
FDEBUG(1) << "\treadEvent\n";
18141814
}
18151815
void EventProcessor::processEvent(unsigned int iStreamIndex) {

FWCore/Framework/src/InputSource.cc

+27-12
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "FWCore/ParameterSet/interface/ParameterSet.h"
2020
#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
2121
#include "FWCore/ServiceRegistry/interface/Service.h"
22+
#include "FWCore/ServiceRegistry/interface/StreamContext.h"
2223
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
2324
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
2425
#include "FWCore/Utilities/interface/do_nothing_deleter.h"
@@ -329,13 +330,17 @@ namespace edm {
329330
}
330331

331332
void
332-
InputSource::readEvent(EventPrincipal& ep, StreamContext* streamContext) {
333+
InputSource::readEvent(EventPrincipal& ep, StreamContext& streamContext) {
333334
assert(state_ == IsEvent);
334335
assert(!eventLimitReached());
336+
{
337+
// block scope, in order to issue the PostSourceEvent signal before calling postRead and issueReports
338+
EventSourceSentry sentry(*this, streamContext);
335339

336-
callWithTryCatchAndPrint<void>( [this,&ep](){ readEvent_(ep); }, "Calling InputSource::readEvent_" );
337-
if(receiver_) {
338-
--numberOfEventsBeforeBigSkip_;
340+
callWithTryCatchAndPrint<void>( [this,&ep](){ readEvent_(ep); }, "Calling InputSource::readEvent_" );
341+
if(receiver_) {
342+
--numberOfEventsBeforeBigSkip_;
343+
}
339344
}
340345

341346
Event event(ep, moduleDescription(), nullptr);
@@ -347,14 +352,17 @@ namespace edm {
347352
}
348353

349354
bool
350-
InputSource::readEvent(EventPrincipal& ep, EventID const& eventID, StreamContext* streamContext) {
355+
InputSource::readEvent(EventPrincipal& ep, EventID const& eventID, StreamContext& streamContext) {
351356
bool result = false;
352357

353-
if(!limitReached()) {
354-
//result = callWithTryCatchAndPrint<bool>( [this,ep,&eventID](){ return readIt(eventID, ep); }, "Calling InputSource::readIt" );
355-
result = readIt(eventID, ep);
356-
if(result) {
358+
if (not limitReached()) {
359+
// the Pre/PostSourceEvent signals should be generated only if the event is actually found.
360+
// this should be taken care of by an EventSourceSentry in the implementaion of readIt()
361+
362+
//result = callWithTryCatchAndPrint<bool>( [this,&eventID,&ep](){ return readIt(eventID, ep); }, "Calling InputSource::readIt" );
363+
result = readIt(eventID, ep, streamContext);
357364

365+
if (result) {
358366
Event event(ep, moduleDescription(), nullptr);
359367
postRead(event);
360368
if(remainingEvents_ > 0) --remainingEvents_;
@@ -409,7 +417,7 @@ namespace edm {
409417
}
410418

411419
bool
412-
InputSource::readIt(EventID const&, EventPrincipal&) {
420+
InputSource::readIt(EventID const&, EventPrincipal&, StreamContext&) {
413421
throw Exception(errors::LogicError)
414422
<< "InputSource::readIt()\n"
415423
<< "Random access is not implemented for this type of Input Source\n"
@@ -608,8 +616,15 @@ namespace edm {
608616
post_();
609617
}
610618

611-
InputSource::EventSourceSentry::EventSourceSentry(InputSource const& source) :
612-
sentry_(source.actReg()->preSourceSignal_, source.actReg()->postSourceSignal_) {
619+
InputSource::EventSourceSentry::EventSourceSentry(InputSource const& source, StreamContext & sc) :
620+
source_(source),
621+
sc_(sc)
622+
{
623+
source.actReg()->preSourceSignal_(sc_.streamID());
624+
}
625+
626+
InputSource::EventSourceSentry::~EventSourceSentry() {
627+
source_.actReg()->postSourceSignal_(sc_.streamID());
613628
}
614629

615630
InputSource::LumiSourceSentry::LumiSourceSentry(InputSource const& source) :

FWCore/Integration/test/ThrowingSource.cc

-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ namespace edm {
130130
ThrowingSource::readEvent_(EventPrincipal& eventPrincipal) {
131131
if (whenToThrow_ == kReadEvent) throw cms::Exception("TestThrow") << "ThrowingSource::readEvent_";
132132
assert(eventCached() || processingMode() != RunsLumisAndEvents);
133-
EventSourceSentry sentry(*this);
134133
EventAuxiliary aux(eventID(), processGUID(), Timestamp(presentTime()), false, EventAuxiliary::Undefined);
135134
eventPrincipal.fillEventPrincipal(aux, processHistoryRegistry());
136135
}

FWCore/MessageService/interface/MessageLogger.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ class MessageLogger {
6464
void postEndJob();
6565
void jobFailure();
6666

67-
void preSource ();
68-
void postSource ();
67+
void preSourceEvent ( StreamID );
68+
void postSourceEvent ( StreamID );
69+
void preSourceRunLumi ();
70+
void postSourceRunLumi ();
6971

70-
void preFile ( std::string const &, bool );
72+
void preFile ( std::string const&, bool );
7173
void preFileClose ( std::string const&, bool );
72-
void postFile ( std::string const &, bool );
74+
void postFile ( std::string const&, bool );
7375

7476
void preModuleConstruction ( ModuleDescription const & );
7577
void postModuleConstruction( ModuleDescription const & );

FWCore/MessageService/src/MessageLogger.cc

+13-12
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,13 @@ namespace edm {
257257
iRegistry.watchPreModuleEvent(this,&MessageLogger::preModuleEvent);
258258
iRegistry.watchPostModuleEvent(this,&MessageLogger::postModuleEvent);
259259

260-
iRegistry.watchPreSource(this,&MessageLogger::preSource);
261-
iRegistry.watchPostSource(this,&MessageLogger::postSource);
260+
iRegistry.watchPreSourceEvent(this,&MessageLogger::preSourceEvent);
261+
iRegistry.watchPostSourceEvent(this,&MessageLogger::postSourceEvent);
262262
// change log 14:
263-
iRegistry.watchPreSourceRun(this,&MessageLogger::preSource);
264-
iRegistry.watchPostSourceRun(this,&MessageLogger::postSource);
265-
iRegistry.watchPreSourceLumi(this,&MessageLogger::preSource);
266-
iRegistry.watchPostSourceLumi(this,&MessageLogger::postSource);
263+
iRegistry.watchPreSourceRun(this,&MessageLogger::preSourceRunLumi);
264+
iRegistry.watchPostSourceRun(this,&MessageLogger::postSourceRunLumi);
265+
iRegistry.watchPreSourceLumi(this,&MessageLogger::preSourceRunLumi);
266+
iRegistry.watchPostSourceLumi(this,&MessageLogger::postSourceRunLumi);
267267
iRegistry.watchPreOpenFile(this,&MessageLogger::preFile);
268268
iRegistry.watchPostOpenFile(this,&MessageLogger::postFile);
269269
iRegistry.watchPreCloseFile(this,&MessageLogger::preFileClose);
@@ -676,12 +676,13 @@ namespace edm {
676676
MessageDrop::instance()->setSinglet("AfterBeginJob"); // Change Log 17
677677
}
678678

679-
void
680-
MessageLogger::preSource()
681-
{
682-
establish("source");
683-
}
684-
void MessageLogger::postSource()
679+
void MessageLogger::preSourceEvent(StreamID)
680+
{ establish("source"); }
681+
void MessageLogger::postSourceEvent(StreamID)
682+
{ unEstablish("AfterSource"); }
683+
void MessageLogger::preSourceRunLumi()
684+
{ establish("source"); }
685+
void MessageLogger::postSourceRunLumi()
685686
{ unEstablish("AfterSource"); }
686687

687688
void MessageLogger::preFile( std::string const &, bool )

FWCore/ServiceRegistry/interface/ActivityRegistry.h

+9-8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ unscheduled execution. The tests are in FWCore/Integration/test:
3131
// system include files
3232
//#include "boost/signal.hpp"
3333
#include "FWCore/Utilities/interface/Signal.h"
34+
#include "FWCore/Utilities/interface/StreamID.h"
3435
#include "boost/bind.hpp"
3536
#include "boost/mem_fn.hpp"
3637
#include "boost/utility.hpp"
@@ -102,20 +103,20 @@ namespace edm {
102103
AR_WATCH_USING_METHOD_0(watchJobFailure)
103104

104105
/// signal is emitted before the source starts creating an Event
105-
typedef signalslot::Signal<void()> PreSource;
106-
PreSource preSourceSignal_;
107-
void watchPreSource(PreSource::slot_type const& iSlot) {
106+
typedef signalslot::Signal<void(StreamID)> PreSourceEvent;
107+
PreSourceEvent preSourceSignal_;
108+
void watchPreSourceEvent(PreSourceEvent::slot_type const& iSlot) {
108109
preSourceSignal_.connect(iSlot);
109110
}
110-
AR_WATCH_USING_METHOD_0(watchPreSource)
111+
AR_WATCH_USING_METHOD_1(watchPreSourceEvent)
111112

112113
/// signal is emitted after the source starts creating an Event
113-
typedef signalslot::Signal<void()> PostSource;
114-
PostSource postSourceSignal_;
115-
void watchPostSource(PostSource::slot_type const& iSlot) {
114+
typedef signalslot::Signal<void(StreamID)> PostSourceEvent;
115+
PostSourceEvent postSourceSignal_;
116+
void watchPostSourceEvent(PostSourceEvent::slot_type const& iSlot) {
116117
postSourceSignal_.connect_front(iSlot);
117118
}
118-
AR_WATCH_USING_METHOD_0(watchPostSource)
119+
AR_WATCH_USING_METHOD_1(watchPostSourceEvent)
119120

120121
/// signal is emitted before the source starts creating a Lumi
121122
typedef signalslot::Signal<void()> PreSourceLumi;

FWCore/Services/src/Memory.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ namespace edm {
143143
if(!oncePerEventMode_) { // default, prints on increases
144144
iReg.watchPreSourceConstruction(this, &SimpleMemoryCheck::preSourceConstruction);
145145
iReg.watchPostSourceConstruction(this, &SimpleMemoryCheck::postSourceConstruction);
146-
iReg.watchPostSource(this, &SimpleMemoryCheck::postSource);
146+
iReg.watchPostSourceEvent(this, &SimpleMemoryCheck::postSourceEvent);
147147
iReg.watchPostModuleConstruction(this, &SimpleMemoryCheck::postModuleConstruction);
148148
iReg.watchPostModuleBeginJob(this, &SimpleMemoryCheck::postModuleBeginJob);
149149
iReg.watchPostEvent(this, &SimpleMemoryCheck::postEvent);
@@ -267,7 +267,7 @@ namespace edm {
267267
}
268268
}
269269

270-
void SimpleMemoryCheck::postSource() {
270+
void SimpleMemoryCheck::postSourceEvent(StreamID sid) {
271271
bool expected = false;
272272
if(measurementUnderway_.compare_exchange_strong(expected,true,std::memory_order_acq_rel) ) {
273273
std::shared_ptr<void> guard(nullptr,[this](void const*) {

FWCore/Services/src/Memory.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace edm {
6262

6363
void preSourceConstruction(const ModuleDescription&);
6464
void postSourceConstruction(const ModuleDescription&);
65-
void postSource();
65+
void postSourceEvent(StreamID);
6666

6767
void postBeginJob();
6868

0 commit comments

Comments
 (0)