Skip to content

Commit

Permalink
Merge pull request #19501 from Dr15Jones/removeStateMachine
Browse files Browse the repository at this point in the history
Replace state machine in EventProcessor
  • Loading branch information
cmsbuild committed Jul 4, 2017
2 parents e2d2d83 + 08e0826 commit d3b3564
Show file tree
Hide file tree
Showing 25 changed files with 913 additions and 5,549 deletions.
100 changes: 52 additions & 48 deletions FWCore/Framework/interface/EventProcessor.h
Expand Up @@ -13,7 +13,6 @@ configured in the user's main() function, and is set running.
#include "DataFormats/Provenance/interface/LuminosityBlockID.h"

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/IEventProcessor.h"
#include "FWCore/Framework/interface/InputSource.h"
#include "FWCore/Framework/interface/PathsAndConsumesOfModules.h"
#include "FWCore/Framework/interface/SharedResourcesAcquirer.h"
Expand All @@ -40,11 +39,6 @@ configured in the user's main() function, and is set running.
#include <exception>
#include <mutex>

namespace statemachine {
class Machine;
class Run;
}

namespace edm {

class ExceptionToActionTable;
Expand All @@ -62,14 +56,25 @@ namespace edm {
class EventSetupsController;
}

class EventProcessor : public IEventProcessor {
class EventProcessor {
public:

// Status codes:
// 0 successful completion
// 1 exception of unknown type caught
// 2 everything else
// 3 signal received
// 4 input complete
// 5 call timed out
// 6 input count complete
enum StatusCode { epSuccess=0, epException=1, epOther=2, epSignal=3,
epInputComplete=4, epTimedOut=5, epCountComplete=6 };

// The input string 'config' contains the entire contents of a configuration file.
// Also allows the attachement of pre-existing services specified by 'token', and
// the specification of services by name only (defaultServices and forcedServices).
// 'defaultServices' are overridden by 'config'.
// 'forcedServices' override the 'config'.
// 'forcedServices' the 'config'.
explicit EventProcessor(std::string const& config,
ServiceToken const& token = ServiceToken(),
serviceregistry::ServiceLegacy = serviceregistry::kOverlapIsError,
Expand Down Expand Up @@ -173,50 +178,55 @@ namespace edm {
// requested by the argument
// epSuccess - all other cases
//
virtual StatusCode runToCompletion() override;
StatusCode runToCompletion();

// The following functions are used by the code implementing our
// boost statemachine
// The following functions are used by the code implementing
// transition handling.

virtual void readFile() override;
virtual void closeInputFile(bool cleaningUpAfterException) override;
virtual void openOutputFiles() override;
virtual void closeOutputFiles() override;
InputSource::ItemType nextTransitionType();
std::pair<edm::ProcessHistoryID, edm::RunNumber_t> nextRunID();
edm::LuminosityBlockNumber_t nextLuminosityBlockID();

void readFile();
void closeInputFile(bool cleaningUpAfterException);
void openOutputFiles();
void closeOutputFiles();

void respondToOpenInputFile();
void respondToCloseInputFile();

virtual void respondToOpenInputFile() override;
virtual void respondToCloseInputFile() override;
void startingNewLoop();
bool endOfLoop();
void rewindInput();
void prepareForNextLoop();
bool shouldWeCloseOutput() const;

virtual void startingNewLoop() override;
virtual bool endOfLoop() override;
virtual void rewindInput() override;
virtual void prepareForNextLoop() override;
virtual bool shouldWeCloseOutput() const override;
void doErrorStuff();

virtual void doErrorStuff() override;
void beginRun(ProcessHistoryID const& phid, RunNumber_t run);
void endRun(ProcessHistoryID const& phid, RunNumber_t run, bool cleaningUpAfterException);

virtual void beginRun(statemachine::Run const& run) override;
virtual void endRun(statemachine::Run const& run, bool cleaningUpAfterException) override;
void beginLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi);
void endLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi, bool cleaningUpAfterException);

virtual void beginLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) override;
virtual void endLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi, bool cleaningUpAfterException) override;
std::pair<ProcessHistoryID,RunNumber_t> readRun();
std::pair<ProcessHistoryID,RunNumber_t> readAndMergeRun();
int readLuminosityBlock();
int readAndMergeLumi();
void writeRun(ProcessHistoryID const& phid, RunNumber_t run);
void deleteRunFromCache(ProcessHistoryID const& phid, RunNumber_t run);
void writeLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi);
void deleteLumiFromCache(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi);

virtual statemachine::Run readRun() override;
virtual statemachine::Run readAndMergeRun() override;
virtual int readLuminosityBlock() override;
virtual int readAndMergeLumi() override;
virtual void writeRun(statemachine::Run const& run) override;
virtual void deleteRunFromCache(statemachine::Run const& run) override;
virtual void writeLumi(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) override;
virtual void deleteLumiFromCache(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) override;
bool shouldWeStop() const;

virtual void readAndProcessEvent() override;
virtual bool shouldWeStop() const override;
void setExceptionMessageFiles(std::string& message);
void setExceptionMessageRuns(std::string& message);
void setExceptionMessageLumis(std::string& message);

virtual void setExceptionMessageFiles(std::string& message) override;
virtual void setExceptionMessageRuns(std::string& message) override;
virtual void setExceptionMessageLumis(std::string& message) override;
bool setDeferredException(std::exception_ptr);

virtual bool alreadyHandlingException() const override;
InputSource::ItemType readAndProcessEvents();

private:
//------------------------------------------------------------------
Expand All @@ -227,9 +237,6 @@ namespace edm {
ServiceToken const& token,
serviceregistry::ServiceLegacy);

void terminateMachine(std::unique_ptr<statemachine::Machine>);
std::unique_ptr<statemachine::Machine> createStateMachine();

bool readNextEventForStream(unsigned int iStreamIndex,
std::atomic<bool>* finishedProcessingEvents);

Expand Down Expand Up @@ -293,13 +300,10 @@ namespace edm {
PrincipalCache principalCache_;
bool beginJobCalled_;
bool shouldWeStop_;
bool stateMachineWasInErrorState_;
std::string fileMode_;
std::string emptyRunLumiMode_;
bool fileModeNoMerge_;
std::string exceptionMessageFiles_;
std::string exceptionMessageRuns_;
std::string exceptionMessageLumis_;
bool alreadyHandlingException_;
bool forceLooperToEnd_;
bool looperBeginJobRun_;
bool forceESCacheClearOnNewRun_;
Expand Down
87 changes: 0 additions & 87 deletions FWCore/Framework/interface/IEventProcessor.h

This file was deleted.

0 comments on commit d3b3564

Please sign in to comment.