Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:14

0001 #ifndef FWCore_Framework_SendSourceTerminationSignalIfException_h
0002 #define FWCore_Framework_SendSourceTerminationSignalIfException_h
0003 //
0004 // Package:     FWCore/Framework
0005 // Class  :     SendSourceTerminationSignalIfException
0006 //
0007 /**\class edm::SendSourceTerminationSignalIfException
0008 */
0009 
0010 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
0011 #include "FWCore/ServiceRegistry/interface/TerminationOrigin.h"
0012 
0013 namespace edm {
0014 
0015   //Sentry class to only send a signal if an
0016   // exception occurs. An exception is identified
0017   // by the destructor being called without first
0018   // calling completedSuccessfully().
0019   class SendSourceTerminationSignalIfException {
0020   public:
0021     SendSourceTerminationSignalIfException(ActivityRegistry* iReg) : reg_(iReg) {}
0022     ~SendSourceTerminationSignalIfException() {
0023       if (reg_) {
0024         reg_->preSourceEarlyTerminationSignal_(TerminationOrigin::ExceptionFromThisContext);
0025       }
0026     }
0027     void completedSuccessfully() { reg_ = nullptr; }
0028 
0029   private:
0030     ActivityRegistry* reg_;  // We do not use propagate_const because the registry itself is mutable.
0031   };
0032 }  // namespace edm
0033 
0034 #endif