Skip to content

Commit

Permalink
Remove CurrentProcessingContext from CMSSW
Browse files Browse the repository at this point in the history
Remove the CurrentProcessingContext class from CMSSW
including all places where it is used, created,
updated and passed around. Uses external to the
Framework were already removed earlier. It was
mostly used in the Framework while handling exceptions.
Fix a bug related to EventSkip exception mode and
unscheduled execution. Also some minor cleanup.
  • Loading branch information
wddgit committed Aug 23, 2013
1 parent 99732ab commit 6fa353c
Show file tree
Hide file tree
Showing 78 changed files with 297 additions and 1,154 deletions.
95 changes: 1 addition & 94 deletions FWCore/Framework/interface/CurrentProcessingContext.h
Original file line number Diff line number Diff line change
@@ -1,94 +1 @@
#ifndef FWCore_Framework_CurrentProcessingContext
#define FWCore_Framework_CurrentProcessingContext

/// CurrentProcessingContext is a class that carries information about
/// the current event processing context. Each module in a framework
/// job can access its CurrentProcessingContext *when that module is
/// active in event processing*. At such a time, the
/// CurrentProcessingContext will provide information about that
/// module's place in the schedule, *as seen at that moment*.
///
/// N.B.: An individual module instance can appear in more than one
/// path; this is why CurrentProcessingContext reports the module's
/// place in the schedule as seen at the time of execution. This is
/// also why the module can not be queried for this information when
/// it is not active in processing.

#include <cstddef> // for size_t
#include <string>

#include "FWCore/Framework/interface/Frameworkfwd.h"

namespace edm {
class CurrentProcessingContext {
public:

/// Default-constructed objects reflect the inactive state.
CurrentProcessingContext();

/// Create a CurrentProcessingContext ready to handle the Path
/// with given name and bit position (slot in Schedule).
CurrentProcessingContext(std::string const* name,
int bitpos, bool isEndPth);

/// The compiler-generated copy c'tor and d'tor are correct,
/// because all our resources are contained by value. We do not
/// own the resources to which we point; we own only the pointers.

/// Return the address of the moduleLabel if the module is active,
/// and null otherwise.
std::string const* moduleLabel() const;


/// Return the name of the current path if the module is active,
/// and null otherwise.
std::string const* pathName() const;

/// Return the address of the ModuleDescription describing this
/// module if active, and null otherwise.
ModuleDescription const* moduleDescription() const;

/// Return the slot number of this path in the schedule (this is
/// the bit position of the path) if the path is active, and -1
/// otherwise.
int pathInSchedule() const;

/// Return the slot number of this module in the path if the path
/// is active, and -1 otherwise.
int slotInPath() const;

/// Return true if the path is an end path, and false otherwise.
bool isEndPath() const;

/// Returns 0 if module is on the path and >0 when the module executing is unscheduled
unsigned int unscheduledDepth() const;

/// Returns true if the module is being called via unscheduled execution
bool isUnscheduled() const;

/// Set the depth in a series of unscheduled callbacks
void setUnscheduledDepth(unsigned int);

/// Set the context to reflect the active state.
void activate(std::size_t theSlotInPath,
ModuleDescription const* mod);

/// Set all data to reflect inactive state.
void deactivate();

private:

// N.B.: We own none of the pointed-to resources!
int pathInSchedule_;
std::size_t slotInPath_;
ModuleDescription const* moduleDescription_;
std::string const* pathName_;
bool isEndPath_;
unsigned int unscheduledDepth_;

bool is_active() const { return moduleDescription_ != 0; }
};
}


#endif
#error CurrentProcessingContext has been deleted from CMSSW and this file should no longer be included.
14 changes: 1 addition & 13 deletions FWCore/Framework/interface/EDAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace edm {
typedef EDAnalyzer ModuleType;
typedef WorkerT<EDAnalyzer> WorkerType;

EDAnalyzer() : moduleDescription_(), current_context_(nullptr) {}
EDAnalyzer() : moduleDescription_() {}
virtual ~EDAnalyzer();

std::string workerType() const {return "WorkerT<EDAnalyzer>";}
Expand All @@ -32,30 +32,20 @@ namespace edm {
// Warning: the returned moduleDescription will be invalid during construction
ModuleDescription const& moduleDescription() const { return moduleDescription_; }

protected:
// The returned pointer will be null unless the this is currently
// executing its event loop function ('analyze').
CurrentProcessingContext const* currentContext() const;

void callWhenNewProductsRegistered(std::function<void(BranchDescription const&)> const& func);

private:
bool doEvent(EventPrincipal const& ep, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
void doBeginJob();
void doEndJob();
bool doBeginRun(RunPrincipal const& rp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
bool doEndRun(RunPrincipal const& rp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
bool doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
bool doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
void doRespondToOpenInputFile(FileBlock const& fb);
void doRespondToCloseInputFile(FileBlock const& fb);
Expand All @@ -80,8 +70,6 @@ namespace edm {
}
ModuleDescription moduleDescription_;

CurrentProcessingContext const* current_context_;

std::function<void(BranchDescription const&)> callWhenNewProductsRegistered_;
};
}
Expand Down
13 changes: 1 addition & 12 deletions FWCore/Framework/interface/EDFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace edm {
typedef EDFilter ModuleType;
typedef WorkerT<EDFilter> WorkerType;

EDFilter() : ProducerBase() , moduleDescription_(), current_context_(nullptr),
EDFilter() : ProducerBase() , moduleDescription_(),
previousParentage_(), previousParentageId_() {
}
virtual ~EDFilter();
Expand All @@ -43,28 +43,18 @@ namespace edm {
// Warning: the returned moduleDescription will be invalid during construction
ModuleDescription const& moduleDescription() const { return moduleDescription_; }

protected:
// The returned pointer will be null unless the this is currently
// executing its event loop function ('filter').
CurrentProcessingContext const* currentContext() const;

private:
bool doEvent(EventPrincipal& ep, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
void doBeginJob();
void doEndJob();
void doBeginRun(RunPrincipal& rp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
void doEndRun(RunPrincipal& rp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
void doBeginLuminosityBlock(LuminosityBlockPrincipal& lbp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
void doEndLuminosityBlock(LuminosityBlockPrincipal& lbp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
void doRespondToOpenInputFile(FileBlock const& fb);
void doRespondToCloseInputFile(FileBlock const& fb);
Expand Down Expand Up @@ -94,7 +84,6 @@ namespace edm {
moduleDescription_ = md;
}
ModuleDescription moduleDescription_;
CurrentProcessingContext const* current_context_;
std::vector<BranchID> previousParentage_;
ParentageID previousParentageId_;
};
Expand Down
11 changes: 0 additions & 11 deletions FWCore/Framework/interface/EDProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,18 @@ namespace edm {
// Warning: the returned moduleDescription will be invalid during construction
ModuleDescription const& moduleDescription() const { return moduleDescription_; }

protected:
// The returned pointer will be null unless the this is currently
// executing its event loop function ('produce').
CurrentProcessingContext const* currentContext() const;

private:
bool doEvent(EventPrincipal& ep, EventSetup const& c,
CurrentProcessingContext const* cpcp,
ModuleCallingContext const* mcc);
void doBeginJob();
void doEndJob();
void doBeginRun(RunPrincipal& rp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
void doEndRun(RunPrincipal& rp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
void doBeginLuminosityBlock(LuminosityBlockPrincipal& lbp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
void doEndLuminosityBlock(LuminosityBlockPrincipal& lbp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
void doRespondToOpenInputFile(FileBlock const& fb);
void doRespondToCloseInputFile(FileBlock const& fb);
Expand Down Expand Up @@ -88,7 +78,6 @@ namespace edm {
moduleDescription_ = md;
}
ModuleDescription moduleDescription_;
CurrentProcessingContext const* current_context_;
std::vector<BranchID> previousParentage_;
ParentageID previousParentageId_;
};
Expand Down
13 changes: 13 additions & 0 deletions FWCore/Framework/interface/EventPrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,19 @@ namespace edm {

private:

class UnscheduledSentry {
public:
UnscheduledSentry(std::vector<std::string>* moduleLabelsRunning, std::string const& moduleLabel) :
moduleLabelsRunning_(moduleLabelsRunning) {
moduleLabelsRunning_->push_back(moduleLabel);
}
~UnscheduledSentry() {
moduleLabelsRunning_->pop_back();
}
private:
std::vector<std::string>* moduleLabelsRunning_;
};

EventAuxiliary aux_;

boost::shared_ptr<LuminosityBlockPrincipal> luminosityBlockPrincipal_;
Expand Down
1 change: 0 additions & 1 deletion FWCore/Framework/interface/Frameworkfwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Forward declarations of types in the EDM.
#include "DataFormats/Provenance/interface/ProvenanceFwd.h"

namespace edm {
class CurrentProcessingContext;
class PrincipalGetAdapter;
class DelayedReader;
class EDAnalyzer;
Expand Down
5 changes: 5 additions & 0 deletions FWCore/Framework/interface/OccurrenceTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
----------------------------------------------------------------------*/

#include "DataFormats/Provenance/interface/LuminosityBlockID.h"
#include "DataFormats/Provenance/interface/ModuleDescription.h"
#include "FWCore/Framework/interface/BranchActionType.h"
#include "FWCore/Framework/interface/EventPrincipal.h"
Expand All @@ -21,10 +22,14 @@
#include "FWCore/ServiceRegistry/interface/ParentContext.h"
#include "FWCore/ServiceRegistry/interface/PathContext.h"
#include "FWCore/ServiceRegistry/interface/StreamContext.h"
#include "FWCore/Utilities/interface/LuminosityBlockIndex.h"

#include<string>

namespace edm {

class ProcessContext;

template <typename T, BranchActionType B> class OccurrenceTraits;

template <>
Expand Down
12 changes: 0 additions & 12 deletions FWCore/Framework/interface/OutputModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,21 @@ namespace edm {
// event.
Trig getTriggerResults(EventPrincipal const& ep, ModuleCallingContext const*) const;

// The returned pointer will be null unless the this is currently
// executing its event loop function ('write').
CurrentProcessingContext const* currentContext() const;

ModuleDescription const& description() const;

ParameterSetID selectorConfig() const { return selector_config_id_; }

void doBeginJob();
void doEndJob();
bool doEvent(EventPrincipal const& ep, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
bool doBeginRun(RunPrincipal const& rp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
bool doEndRun(RunPrincipal const& rp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
bool doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);
bool doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
CurrentProcessingContext const* cpc,
ModuleCallingContext const* mcc);

void setEventSelectionInfo(std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
Expand Down Expand Up @@ -148,9 +139,6 @@ namespace edm {
ProductSelector productSelector_;
ModuleDescription moduleDescription_;

// We do not own the pointed-to CurrentProcessingContext.
CurrentProcessingContext const* current_context_;

bool wantAllEvents_;
mutable detail::TriggerResultsBasedEventSelector selectors_;
// ID of the ParameterSet that configured the event selector
Expand Down
1 change: 1 addition & 0 deletions FWCore/Framework/interface/Principal.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pointer to a ProductHolder, when queried.
namespace edm {

class HistoryAppender;
class ModuleCallingContext;
class ProductHolderIndexHelper;
class EDConsumerBase;

Expand Down
1 change: 1 addition & 0 deletions FWCore/Framework/interface/RunPrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ is the DataBlock.
namespace edm {

class HistoryAppender;
class ModuleCallingContext;
class UnscheduledHandler;

class RunPrincipal : public Principal {
Expand Down
24 changes: 14 additions & 10 deletions FWCore/Framework/interface/Schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@
#include "FWCore/MessageLogger/interface/ExceptionMessages.h"
#include "FWCore/MessageLogger/interface/JobReport.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/GlobalContext.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/ServiceRegistry/interface/StreamContext.h"
#include "FWCore/Utilities/interface/Algorithms.h"
#include "FWCore/Utilities/interface/BranchType.h"
#include "FWCore/Utilities/interface/ConvertException.h"
Expand All @@ -92,6 +94,16 @@

namespace edm {

class ActivityRegistry;
class BranchIDListHelper;
class EventSetup;
class ExceptionCollector;
class OutputModuleCommunicator;
class ProcessContext;
class RunStopwatch;
class UnscheduledCallProducer;
class WorkerInPath;

namespace {
template <typename T>
class ScheduleSignalSentry {
Expand All @@ -116,15 +128,7 @@ namespace edm {
namespace service {
class TriggerNamesService;
}
class ActivityRegistry;
class BranchIDListHelper;
class EventSetup;
class ExceptionCollector;
class OutputModuleCommunicator;
class ProcessContext;
class RunStopwatch;
class UnscheduledCallProducer;
class WorkerInPath;

class Schedule {
public:
typedef std::vector<std::string> vstring;
Expand Down Expand Up @@ -407,7 +411,7 @@ namespace edm {
try {
CPUTimer timer;
ParentContext parentContext(&streamContext_);
if (results_inserter_.get()) results_inserter_->doWork<T>(ep, es, nullptr, &timer,streamID_, parentContext, &streamContext_);
if (results_inserter_.get()) results_inserter_->doWork<T>(ep, es, &timer,streamID_, parentContext, &streamContext_);
}
catch (cms::Exception & ex) {
if (T::isEvent_) {
Expand Down
1 change: 0 additions & 1 deletion FWCore/Framework/interface/SubProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace edm {
class EDLooperBase;
class HistoryAppender;
class IOVSyncValue;
class ModuleCallingContext;
class ParameterSet;
class ProductRegistry;
namespace eventsetup {
Expand Down
Loading

0 comments on commit 6fa353c

Please sign in to comment.