CMS 3D CMS Logo

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/thread/mutex.hpp"
00025 namespace edm {
00026   namespace rootfix {
00027   
00028     class LockService
00029     {
00030     public:
00031       LockService(const edm::ParameterSet&,edm::ActivityRegistry&);
00032       ~LockService();
00033       
00034       boost::mutex& getLock() { return *lock_; }
00035       
00036       void postBeginJob();
00037       void postEndJob();
00038       
00039       void preSourceConstruction(const edm::ModuleDescription&);
00040       void postSourceConstruction(const edm::ModuleDescription&);
00041       
00042       void preEventProcessing(const edm::EventID&, const edm::Timestamp&);
00043       void postEventProcessing(const edm::Event&, const edm::EventSetup&);
00044       
00045       void preSource();
00046       void postSource();
00047       
00048       
00049       void preModule(const edm::ModuleDescription&);
00050       void postModule(const edm::ModuleDescription&);
00051       
00052     private:
00053       boost::mutex* lock_;
00054       boost::mutex::scoped_lock* locker_; // what a hack!
00055       typedef std::vector<std::string> Labels;
00056       Labels labels_;
00057       bool lockSources_;
00058     };
00059   }
00060 }
00061 
00062 #endif

Generated on Tue Jun 9 17:36:39 2009 for CMSSW by  doxygen 1.5.4