Skip to content

Commit

Permalink
Merge pull request #21872 from fwyzard/Update_pre_post_Source_Lumi_Ru…
Browse files Browse the repository at this point in the history
…n_signals_100pre4

Update the (pre|post)Source(Lumi|Run) signals
  • Loading branch information
cmsbuild authored Jan 28, 2018
2 parents 46be6bb + 5b8e8d2 commit 10b588d
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 82 deletions.
15 changes: 15 additions & 0 deletions DQMServices/Core/interface/Standalone.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# include "FWCore/ServiceRegistry/interface/Service.h"
# include "FWCore/ServiceRegistry/interface/ServiceRegistry.h"
# include "FWCore/ServiceRegistry/interface/SystemBounds.h"
# include "FWCore/Utilities/interface/LuminosityBlockIndex.h"
# include "FWCore/Utilities/interface/RunIndex.h"
# include "FWCore/Version/interface/GetReleaseVersion.h"
# else
# include <memory>
Expand Down Expand Up @@ -78,6 +80,12 @@ namespace edm
template <typename T>
void watchPostSourceLumi(void*, T) {}

template <typename F>
void watchPostSourceRun(F) {}

template <typename F>
void watchPostSourceLumi(F) {}

template <typename T>
void watchPostGlobalBeginRun(void*, T) {}

Expand Down Expand Up @@ -112,6 +120,13 @@ namespace edm
JobReport(const edm::ParameterSet &) {}
void reportAnalysisFile(const std::string &, const std::map<std::string, std::string> &) {}
};

class LuminosityBlockIndex
{ };

class RunIndex
{ };

}
# endif // WITHOUT_CMS_FRAMEWORK
#endif // DQMSERVICES_CORE_STANDALONE_H
4 changes: 2 additions & 2 deletions DQMServices/Core/src/DQMStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,11 @@ DQMStore::DQMStore(const edm::ParameterSet &pset, edm::ActivityRegistry& ar)
}
});
if(pset.getUntrackedParameter<bool>("forceResetOnBeginRun",false)) {
ar.watchPostSourceRun(this,&DQMStore::forceReset);
ar.watchPostSourceRun([this](edm::RunIndex){ forceReset(); });
}
if(pset.getUntrackedParameter<bool>("forceResetOnBeginLumi",false) && enableMultiThread_ == false) {
forceResetOnBeginLumi_ = true;
ar.watchPostSourceLumi(this,&DQMStore::forceReset);
ar.watchPostSourceLumi([this](edm::LuminosityBlockIndex){ forceReset(); });
}
ar.watchPostGlobalBeginLumi(this, &DQMStore::postGlobalBeginLumi);
}
Expand Down
36 changes: 18 additions & 18 deletions FWCore/Framework/interface/InputSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Some examples of InputSource subclasses may be:
#include "DataFormats/Provenance/interface/Timestamp.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/ProcessingController.h"

#include "FWCore/Utilities/interface/LuminosityBlockIndex.h"
#include "FWCore/Utilities/interface/RunIndex.h"
#include "FWCore/Utilities/interface/Signal.h"
#include "FWCore/Utilities/interface/get_underlying_safe.h"

Expand Down Expand Up @@ -256,19 +257,6 @@ namespace edm {
ProcessingController::ForwardState forwardState() const;
ProcessingController::ReverseState reverseState() const;

class SourceSentry {
public:
typedef signalslot::Signal<void()> Sig;
SourceSentry(Sig& pre, Sig& post);
~SourceSentry();

SourceSentry(SourceSentry const&) = delete; // Disallow copying and moving
SourceSentry& operator=(SourceSentry const&) = delete; // Disallow copying and moving

private:
Sig& post_;
};

class EventSourceSentry {
public:
EventSourceSentry(InputSource const& source, StreamContext & sc);
Expand All @@ -284,16 +272,28 @@ namespace edm {

class LumiSourceSentry {
public:
explicit LumiSourceSentry(InputSource const& source);
LumiSourceSentry(InputSource const& source, LuminosityBlockIndex id);
~LumiSourceSentry();

LumiSourceSentry(LumiSourceSentry const&) = delete; // Disallow copying and moving
LumiSourceSentry& operator=(LumiSourceSentry const&) = delete; // Disallow copying and moving

private:
SourceSentry sentry_;
InputSource const& source_;
LuminosityBlockIndex index_;
};

class RunSourceSentry {
public:
explicit RunSourceSentry(InputSource const& source);
RunSourceSentry(InputSource const& source, RunIndex id);
~RunSourceSentry();

RunSourceSentry(RunSourceSentry const&) = delete; // Disallow copying and moving
RunSourceSentry& operator=(RunSourceSentry const&) = delete; // Disallow copying and moving

private:
SourceSentry sentry_;
InputSource const& source_;
RunIndex index_;
};

class FileOpenSentry {
Expand Down
38 changes: 22 additions & 16 deletions FWCore/Framework/src/InputSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,19 +262,19 @@ namespace edm {

void
InputSource::readRun(RunPrincipal& runPrincipal, HistoryAppender& ) {
RunSourceSentry sentry(*this);
RunSourceSentry sentry(*this, runPrincipal.index());
callWithTryCatchAndPrint<void>( [this,&runPrincipal](){ readRun_(runPrincipal); }, "Calling InputSource::readRun_" );
}

void
InputSource::readAndMergeRun(RunPrincipal& rp) {
RunSourceSentry sentry(*this);
RunSourceSentry sentry(*this, rp.index());
callWithTryCatchAndPrint<void>( [this,&rp](){ readRun_(rp); }, "Calling InputSource::readRun_" );
}

void
InputSource::readLuminosityBlock(LuminosityBlockPrincipal& lumiPrincipal, HistoryAppender& ) {
LumiSourceSentry sentry(*this);
LumiSourceSentry sentry(*this, lumiPrincipal.index());
callWithTryCatchAndPrint<void>( [this,&lumiPrincipal](){ readLuminosityBlock_(lumiPrincipal); }, "Calling InputSource::readLuminosityBlock_" );
if(remainingLumis_ > 0) {
--remainingLumis_;
Expand All @@ -283,7 +283,7 @@ namespace edm {

void
InputSource::readAndMergeLumi(LuminosityBlockPrincipal& lbp) {
LumiSourceSentry sentry(*this);
LumiSourceSentry sentry(*this, lbp.index());
callWithTryCatchAndPrint<void>( [this,&lbp](){ readLuminosityBlock_(lbp); }, "Calling InputSource::readLuminosityBlock_" );
if(remainingLumis_ > 0) {
--remainingLumis_;
Expand Down Expand Up @@ -512,14 +512,6 @@ namespace edm {
return luminosityBlockAuxiliary()->luminosityBlock();
}

InputSource::SourceSentry::SourceSentry(Sig& pre, Sig& post) : post_(post) {
pre();
}

InputSource::SourceSentry::~SourceSentry() {
post_();
}

InputSource::EventSourceSentry::EventSourceSentry(InputSource const& source, StreamContext & sc) :
source_(source),
sc_(sc)
Expand All @@ -531,12 +523,26 @@ namespace edm {
source_.actReg()->postSourceSignal_(sc_.streamID());
}

InputSource::LumiSourceSentry::LumiSourceSentry(InputSource const& source) :
sentry_(source.actReg()->preSourceLumiSignal_, source.actReg()->postSourceLumiSignal_) {
InputSource::LumiSourceSentry::LumiSourceSentry(InputSource const& source, LuminosityBlockIndex index) :
source_(source),
index_(index)
{
source_.actReg()->preSourceLumiSignal_(index_);
}

InputSource::LumiSourceSentry::~LumiSourceSentry() {
source_.actReg()->postSourceLumiSignal_(index_);
}

InputSource::RunSourceSentry::RunSourceSentry(InputSource const& source, RunIndex index) :
source_(source),
index_(index)
{
source_.actReg()->preSourceRunSignal_(index_);
}

InputSource::RunSourceSentry::RunSourceSentry(InputSource const& source) :
sentry_(source.actReg()->preSourceRunSignal_, source.actReg()->postSourceRunSignal_) {
InputSource::RunSourceSentry::~RunSourceSentry() {
source_.actReg()->postSourceRunSignal_(index_);
}

InputSource::FileOpenSentry::FileOpenSentry(InputSource const& source,
Expand Down
8 changes: 4 additions & 4 deletions FWCore/MessageService/src/MessageLogger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ namespace edm {
iRegistry.watchPreSourceEvent(this,&MessageLogger::preSourceEvent);
iRegistry.watchPostSourceEvent(this,&MessageLogger::postSourceEvent);
// change log 14:
iRegistry.watchPreSourceRun(this,&MessageLogger::preSourceRunLumi);
iRegistry.watchPostSourceRun(this,&MessageLogger::postSourceRunLumi);
iRegistry.watchPreSourceLumi(this,&MessageLogger::preSourceRunLumi);
iRegistry.watchPostSourceLumi(this,&MessageLogger::postSourceRunLumi);
iRegistry.watchPreSourceRun([this](RunIndex) { preSourceRunLumi(); });
iRegistry.watchPostSourceRun([this](RunIndex) { postSourceRunLumi(); });
iRegistry.watchPreSourceLumi([this](LuminosityBlockIndex) { preSourceRunLumi(); });
iRegistry.watchPostSourceLumi([this](LuminosityBlockIndex) { postSourceRunLumi(); });
iRegistry.watchPreOpenFile(this,&MessageLogger::preFile);
iRegistry.watchPostOpenFile(this,&MessageLogger::postFile);
iRegistry.watchPreCloseFile(this,&MessageLogger::preFileClose);
Expand Down
25 changes: 14 additions & 11 deletions FWCore/ServiceRegistry/interface/ActivityRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ unscheduled execution. The tests are in FWCore/Integration/test:

// system include files
#include <functional>
#include "FWCore/Utilities/interface/Signal.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "FWCore/ServiceRegistry/interface/TerminationOrigin.h"

// user include files
#include "FWCore/ServiceRegistry/interface/TerminationOrigin.h"
#include "FWCore/Utilities/interface/LuminosityBlockIndex.h"
#include "FWCore/Utilities/interface/RunIndex.h"
#include "FWCore/Utilities/interface/Signal.h"
#include "FWCore/Utilities/interface/StreamID.h"

#define AR_WATCH_USING_METHOD_0(method) template<class TClass, class TMethod> void method (TClass* iObject, TMethod iMethod) { method (std::bind(std::mem_fn(iMethod), iObject)); }
#define AR_WATCH_USING_METHOD_1(method) template<class TClass, class TMethod> void method (TClass* iObject, TMethod iMethod) { method (std::bind(std::mem_fn(iMethod), iObject, std::placeholders::_1)); }
Expand Down Expand Up @@ -99,6 +101,7 @@ namespace edm {
}
AR_WATCH_USING_METHOD_1(watchPreallocate)


typedef signalslot::Signal<void(PathsAndConsumesOfModulesBase const&, ProcessContext const&)> PreBeginJob;
///signal is emitted before all modules have gotten their beginJob called
PreBeginJob preBeginJobSignal_;
Expand Down Expand Up @@ -160,36 +163,36 @@ namespace edm {
AR_WATCH_USING_METHOD_1(watchPostSourceEvent)

/// signal is emitted before the source starts creating a Lumi
typedef signalslot::Signal<void()> PreSourceLumi;
typedef signalslot::Signal<void(LuminosityBlockIndex)> PreSourceLumi;
PreSourceLumi preSourceLumiSignal_;
void watchPreSourceLumi(PreSourceLumi::slot_type const& iSlot) {
preSourceLumiSignal_.connect(iSlot);
}
AR_WATCH_USING_METHOD_0(watchPreSourceLumi)
AR_WATCH_USING_METHOD_1(watchPreSourceLumi)

/// signal is emitted after the source starts creating a Lumi
typedef signalslot::Signal<void()> PostSourceLumi;
typedef signalslot::Signal<void(LuminosityBlockIndex)> PostSourceLumi;
PostSourceLumi postSourceLumiSignal_;
void watchPostSourceLumi(PostSourceLumi::slot_type const& iSlot) {
postSourceLumiSignal_.connect_front(iSlot);
}
AR_WATCH_USING_METHOD_0(watchPostSourceLumi)
AR_WATCH_USING_METHOD_1(watchPostSourceLumi)

/// signal is emitted before the source starts creating a Run
typedef signalslot::Signal<void()> PreSourceRun;
typedef signalslot::Signal<void(RunIndex)> PreSourceRun;
PreSourceRun preSourceRunSignal_;
void watchPreSourceRun(PreSourceRun::slot_type const& iSlot) {
preSourceRunSignal_.connect(iSlot);
}
AR_WATCH_USING_METHOD_0(watchPreSourceRun)
AR_WATCH_USING_METHOD_1(watchPreSourceRun)

/// signal is emitted after the source starts creating a Run
typedef signalslot::Signal<void()> PostSourceRun;
typedef signalslot::Signal<void(RunIndex)> PostSourceRun;
PostSourceRun postSourceRunSignal_;
void watchPostSourceRun(PostSourceRun::slot_type const& iSlot) {
postSourceRunSignal_.connect_front(iSlot);
}
AR_WATCH_USING_METHOD_0(watchPostSourceRun)
AR_WATCH_USING_METHOD_1(watchPostSourceRun)

/// signal is emitted before the source opens a file
typedef signalslot::Signal<void(std::string const&, bool)> PreOpenFile;
Expand Down
16 changes: 8 additions & 8 deletions FWCore/Services/plugins/Timing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ namespace edm {
void preSourceEvent(StreamID);
void postSourceEvent(StreamID);

void preSourceLumi();
void postSourceLumi();
void preSourceLumi(LuminosityBlockIndex);
void postSourceLumi(LuminosityBlockIndex);

void preSourceRun();
void postSourceRun();
void preSourceRun(RunIndex);
void postSourceRun(RunIndex);

void preOpenFile(std::string const&, bool);
void postOpenFile(std::string const&, bool);
Expand Down Expand Up @@ -423,19 +423,19 @@ namespace edm {
postCommon();
}

void Timing::preSourceLumi() {
void Timing::preSourceLumi(LuminosityBlockIndex index) {
pushStack();
}

void Timing::postSourceLumi() {
void Timing::postSourceLumi(LuminosityBlockIndex index) {
postCommon();
}

void Timing::preSourceRun() {
void Timing::preSourceRun(RunIndex index) {
pushStack();
}

void Timing::postSourceRun() {
void Timing::postSourceRun(RunIndex index) {
postCommon();
}

Expand Down
16 changes: 8 additions & 8 deletions FWCore/Services/plugins/Tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ namespace edm {
void preSourceEvent(StreamID);
void postSourceEvent(StreamID);

void preSourceLumi();
void postSourceLumi();
void preSourceLumi(LuminosityBlockIndex);
void postSourceLumi(LuminosityBlockIndex);

void preSourceRun();
void postSourceRun();
void preSourceRun(RunIndex);
void postSourceRun(RunIndex);

void preOpenFile(std::string const&, bool);
void postOpenFile(std::string const&, bool);
Expand Down Expand Up @@ -475,22 +475,22 @@ Tracer::postSourceEvent(StreamID sid) {
}

void
Tracer::preSourceLumi() {
Tracer::preSourceLumi(LuminosityBlockIndex index) {
LogAbsolute("Tracer") << TimeStamper(printTimestamps_) << indention_ << indention_ << " starting: source lumi";
}

void
Tracer::postSourceLumi() {
Tracer::postSourceLumi(LuminosityBlockIndex index) {
LogAbsolute("Tracer") << TimeStamper(printTimestamps_) << indention_ << indention_ << " finished: source lumi";
}

void
Tracer::preSourceRun() {
Tracer::preSourceRun(RunIndex index) {
LogAbsolute("Tracer") << TimeStamper(printTimestamps_) << indention_ << indention_ << " starting: source run";
}

void
Tracer::postSourceRun() {
Tracer::postSourceRun(RunIndex index) {
LogAbsolute("Tracer") << TimeStamper(printTimestamps_) << indention_ << indention_ << " finished: source run";
}

Expand Down
10 changes: 5 additions & 5 deletions FWCore/Services/plugins/ZombieKillerService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ m_numberChecksWhenNotAlive(0)
iRegistry.watchPostBeginJob([this](){ startThread(); } );
iRegistry.watchPostEndJob([this]() {stopThread(); } );

iRegistry.watchPreSourceRun([this](){notAZombieYet();});
iRegistry.watchPostSourceRun([this](){notAZombieYet();});
iRegistry.watchPreSourceRun([this](RunIndex){notAZombieYet();});
iRegistry.watchPostSourceRun([this](RunIndex){notAZombieYet();});

iRegistry.watchPreSourceLumi([this](){notAZombieYet();});
iRegistry.watchPostSourceLumi([this](){notAZombieYet();});
iRegistry.watchPreSourceLumi([this](LuminosityBlockIndex){notAZombieYet();});
iRegistry.watchPostSourceLumi([this](LuminosityBlockIndex){notAZombieYet();});

iRegistry.watchPreSourceEvent([this](StreamID){notAZombieYet();});
iRegistry.watchPostSourceEvent([this](StreamID){notAZombieYet();});
Expand Down Expand Up @@ -213,4 +213,4 @@ ZombieKillerService::fillDescriptions(ConfigurationDescriptions& descriptions) {
// static member functions
//

DEFINE_FWK_SERVICE(ZombieKillerService);
DEFINE_FWK_SERVICE(ZombieKillerService);
8 changes: 4 additions & 4 deletions HLTrigger/Timer/interface/FastTimerService.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ class FastTimerService : public tbb::task_scheduler_observer
void preSourceConstruction(edm::ModuleDescription const&);
//void postSourceConstruction(edm::ModuleDescription const&);

void preSourceRun();
void postSourceRun();
void preSourceRun(edm::RunIndex);
void postSourceRun(edm::RunIndex);

void preSourceLumi();
void postSourceLumi();
void preSourceLumi(edm::LuminosityBlockIndex);
void postSourceLumi(edm::LuminosityBlockIndex);

void preSourceEvent(edm::StreamID);
void postSourceEvent(edm::StreamID);
Expand Down
Loading

0 comments on commit 10b588d

Please sign in to comment.