19
19
#include " FWCore/ParameterSet/interface/ParameterSet.h"
20
20
#include " FWCore/ServiceRegistry/interface/ActivityRegistry.h"
21
21
#include " FWCore/ServiceRegistry/interface/Service.h"
22
+ #include " FWCore/ServiceRegistry/interface/StreamContext.h"
22
23
#include " FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
23
24
#include " FWCore/ParameterSet/interface/ParameterSetDescription.h"
24
25
#include " FWCore/Utilities/interface/do_nothing_deleter.h"
@@ -329,13 +330,17 @@ namespace edm {
329
330
}
330
331
331
332
void
332
- InputSource::readEvent (EventPrincipal& ep, StreamContext* streamContext) {
333
+ InputSource::readEvent (EventPrincipal& ep, StreamContext& streamContext) {
333
334
assert (state_ == IsEvent);
334
335
assert (!eventLimitReached ());
336
+ {
337
+ // block scope, in order to issue the PostSourceEvent signal before calling postRead and issueReports
338
+ EventSourceSentry sentry (*this , streamContext);
335
339
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
+ }
339
344
}
340
345
341
346
Event event (ep, moduleDescription (), nullptr );
@@ -347,14 +352,17 @@ namespace edm {
347
352
}
348
353
349
354
bool
350
- InputSource::readEvent (EventPrincipal& ep, EventID const & eventID, StreamContext* streamContext) {
355
+ InputSource::readEvent (EventPrincipal& ep, EventID const & eventID, StreamContext& streamContext) {
351
356
bool result = false ;
352
357
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);
357
364
365
+ if (result) {
358
366
Event event (ep, moduleDescription (), nullptr );
359
367
postRead (event);
360
368
if (remainingEvents_ > 0 ) --remainingEvents_;
@@ -409,7 +417,7 @@ namespace edm {
409
417
}
410
418
411
419
bool
412
- InputSource::readIt (EventID const &, EventPrincipal&) {
420
+ InputSource::readIt (EventID const &, EventPrincipal&, StreamContext& ) {
413
421
throw Exception (errors::LogicError)
414
422
<< " InputSource::readIt()\n "
415
423
<< " Random access is not implemented for this type of Input Source\n "
@@ -608,8 +616,15 @@ namespace edm {
608
616
post_ ();
609
617
}
610
618
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 ());
613
628
}
614
629
615
630
InputSource::LumiSourceSentry::LumiSourceSentry (InputSource const & source) :
0 commit comments