All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ThreadsafeGalleryEvent.h
Go to the documentation of this file.
1 #ifndef WEBEVD_THREADSAFEGALLERYEVENT_H
2 #define WEBEVD_THREADSAFEGALLERYEVENT_H
3 
4 #include "gallery/Event.h"
5 
6 #include <mutex>
7 
8 namespace evd
9 {
10  /// gallery::Event is not designed to be threadsafe. Serializing calls
11  /// through this wrapper should be more efficient than giving up on threading
12  /// as a whole. This way we can still write and transfer the PNGs in parallel
13  /// for example.
15  {
16  public:
17  template<class PROD> using HandleT = gallery::Event::template HandleT<PROD>;
18 
19  ThreadsafeGalleryEvent(const gallery::Event* evt) : fEvt(evt)
20  {
21  }
22 
23  template<class T>
24  bool getByLabel(const art::InputTag& tag, gallery::Handle<T>& result) const
25  {
26  std::lock_guard guard(fLock);
27  return fEvt->getByLabel(tag, result);
28  }
29 
30  template<class T>
31  std::vector<art::InputTag> getInputTags() const
32  {
33  std::lock_guard guard(fLock);
34  return fEvt->getInputTags<T>();
35  }
36 
37  const art::EventAuxiliary& eventAuxiliary() const
38  {
39  std::lock_guard guard(fLock);
40  return fEvt->eventAuxiliary();
41  }
42 
43  protected:
44  mutable std::mutex fLock;
45  const gallery::Event* fEvt;
46  };
47 }
48 
49 #endif
ThreadsafeGalleryEvent(const gallery::Event *evt)
std::vector< art::InputTag > getInputTags() const
const art::EventAuxiliary & eventAuxiliary() const
gallery::Event::template HandleT< PROD > HandleT
TCEvent evt
Definition: DataStructs.cxx:8
bool getByLabel(const art::InputTag &tag, gallery::Handle< T > &result) const