CMS 3D CMS Logo

ThreadSafeStringCut.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_EgammaTools_ThreadSafeStringCut_H
2 #define RecoEgamma_EgammaTools_ThreadSafeStringCut_H
3 
6 
7 #include <mutex>
9 
10 /*
11  * This class is a simple wrapper around either a StringObjectFunction or
12  * StringCutObjectSelector to use them in a thread safe way.
13  *
14  */
15 
16 template <class F, class T>
18 public:
19  ThreadSafeStringCut(const std::string& expr) // constructor
20  : func_(expr), expr_(expr) {}
21 
22  ThreadSafeStringCut(ThreadSafeStringCut&& other) noexcept // move constructor
23  : func_(std::move(other.func_)), expr_(std::move(other.expr_)) {}
24 
25  typename std::invoke_result_t<F, T> operator()(const T& t) const {
26  std::lock_guard<std::mutex> guard(mutex_);
27  return func_(t);
28  }
29 
30 private:
31  const F func_;
34 };
35 
36 #endif
ThreadSafeStringCut::operator()
std::invoke_result_t< F, T > operator()(const T &t) const
Definition: ThreadSafeStringCut.h:25
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
ThreadSafeStringCut
Definition: ThreadSafeStringCut.h:17
ThreadSafeStringCut::ThreadSafeStringCut
ThreadSafeStringCut(ThreadSafeStringCut &&other) noexcept
Definition: ThreadSafeStringCut.h:22
ThreadSafeStringCut::ThreadSafeStringCut
ThreadSafeStringCut(const std::string &expr)
Definition: ThreadSafeStringCut.h:19
trackingPlots.other
other
Definition: trackingPlots.py:1465
CMS_THREAD_SAFE
#define CMS_THREAD_SAFE
Definition: thread_safety_macros.h:4
mutex
static boost::mutex mutex
Definition: Proxy.cc:9
OrderedSet.t
t
Definition: OrderedSet.py:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ThreadSafeStringCut::func_
const F func_
Definition: ThreadSafeStringCut.h:31
thread_safety_macros.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
StringCutObjectSelector.h
jets_cff.expr
expr
Definition: jets_cff.py:449
T
long double T
Definition: Basic3DVectorLD.h:48
ThreadSafeStringCut::mutex_
std::mutex mutex_
Definition: ThreadSafeStringCut.h:33
StringObjectFunction.h
ThreadSafeStringCut::expr_
const std::string expr_
Definition: ThreadSafeStringCut.h:32