CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/FWCore/Services/src/LockService.h

Go to the documentation of this file.
00001 #ifndef FWCore_Services_LockService_h
00002 #define FWCore_Services_LockService_h
00003 
00004 /*
00005   This class exists to only allow because ROOT is not thread-safe in its
00006   serialization/deserialization process at the moment.  It will hopefully
00007   be so very soon.  Here we have serialized access to some resource
00008   i.e. the one locking the mutex, where modules (using the module labels
00009   to identify them) are prevented from accessing that resource while running.
00010 
00011   There is only one mutex for the entire system.  We count one service
00012   object being constructed per thread that an event processor runs in.
00013   The current system only makes one event processor in one thread.
00014   If more than one event processor in more than one thread in the future,
00015   then I need to ensure that the service registry is not shared between
00016   any two threads running event processors.
00017  */
00018 
00019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00020 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
00021 
00022 #include <string>
00023 #include <vector>
00024 #include "boost/shared_ptr.hpp"
00025 #include "boost/thread/mutex.hpp"
00026 namespace edm {
00027   class ConfigurationDescriptions;
00028 
00029   namespace rootfix {
00030   
00031     class LockService
00032     {
00033     public:
00034       LockService(const edm::ParameterSet&,edm::ActivityRegistry&);
00035       ~LockService();
00036       
00037       static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
00038 
00039       boost::mutex& getLock() { return lock_; }
00040       
00041       void postBeginJob();
00042       void postEndJob();
00043       
00044       void preSourceConstruction(const edm::ModuleDescription&);
00045       void postSourceConstruction(const edm::ModuleDescription&);
00046       
00047       void preEventProcessing(const edm::EventID&, const edm::Timestamp&);
00048       void postEventProcessing(const edm::Event&, const edm::EventSetup&);
00049       
00050       void preSource();
00051       void postSource();
00052       
00053       
00054       void preModule(const edm::ModuleDescription&);
00055       void postModule(const edm::ModuleDescription&);
00056       
00057     private:
00058       boost::mutex& lock_;
00059       boost::shared_ptr<boost::mutex::scoped_lock> locker_; // what a hack!
00060       typedef std::vector<std::string> Labels;
00061       Labels labels_;
00062       bool lockSources_;
00063     };
00064   }
00065 }
00066 
00067 #endif