CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LockService.h
Go to the documentation of this file.
1 #ifndef FWCore_Services_LockService_h
2 #define FWCore_Services_LockService_h
3 
4 /*
5  This class exists to only allow because ROOT is not thread-safe in its
6  serialization/deserialization process at the moment. It will hopefully
7  be so very soon. Here we have serialized access to some resource
8  i.e. the one locking the mutex, where modules (using the module labels
9  to identify them) are prevented from accessing that resource while running.
10 
11  There is only one mutex for the entire system. We count one service
12  object being constructed per thread that an event processor runs in.
13  The current system only makes one event processor in one thread.
14  If more than one event processor in more than one thread in the future,
15  then I need to ensure that the service registry is not shared between
16  any two threads running event processors.
17  */
18 
21 
22 #include <string>
23 #include <vector>
24 #include "boost/shared_ptr.hpp"
25 #include "boost/thread/mutex.hpp"
26 namespace edm {
28 
29  namespace rootfix {
30 
32  {
33  public:
35  ~LockService();
36 
37  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
38 
39  boost::mutex& getLock() { return lock_; }
40 
41  void postBeginJob();
42  void postEndJob();
43 
46 
47  void preEventProcessing(const edm::EventID&, const edm::Timestamp&);
48  void postEventProcessing(const edm::Event&, const edm::EventSetup&);
49 
50  void preSource();
51  void postSource();
52 
53 
54  void preModule(const edm::ModuleDescription&);
56 
57  private:
59  boost::shared_ptr<boost::mutex::scoped_lock> locker_; // what a hack!
60  typedef std::vector<std::string> Labels;
63  };
64  }
65 }
66 
67 #endif
void preModule(const edm::ModuleDescription &)
Definition: LockService.cc:85
void preSourceConstruction(const edm::ModuleDescription &)
Definition: LockService.cc:47
std::vector< std::string > Labels
Definition: LockService.h:60
static boost::mutex mutex
Definition: LHEProxy.cc:11
void preEventProcessing(const edm::EventID &, const edm::Timestamp &)
Definition: LockService.cc:67
void postEventProcessing(const edm::Event &, const edm::EventSetup &)
Definition: LockService.cc:70
LockService(const edm::ParameterSet &, edm::ActivityRegistry &)
Definition: LockService.cc:13
void postSourceConstruction(const edm::ModuleDescription &)
Definition: LockService.cc:56
boost::mutex & getLock()
Definition: LockService.h:39
boost::shared_ptr< boost::mutex::scoped_lock > locker_
Definition: LockService.h:59
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: LockService.cc:39
boost::mutex & lock_
Definition: LockService.h:58
void postModule(const edm::ModuleDescription &)
Definition: LockService.cc:93