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 {
19  public:
20 
21  ThreadSafeStringCut(const std::string & expr) // constructor
22  : func_(expr)
23  , expr_(expr)
24  {}
25 
27  : func_(std::move(other.func_))
28  , expr_(std::move(other.expr_))
29  {}
30 
31  typename std::invoke_result_t<F,T> operator()(const T & t) const
32  {
33  std::lock_guard<std::mutex> guard(mutex_);
34  return func_(t);
35  }
36 
37  private:
38 
39  const F func_;
42 };
43 
44 #endif
static boost::mutex mutex
Definition: Proxy.cc:11
std::invoke_result_t< F, T > operator()(const T &t) const
ThreadSafeStringCut(const std::string &expr)
const std::string expr_
#define CMS_THREAD_SAFE
#define noexcept
ThreadSafeStringCut(ThreadSafeStringCut &&other)
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
long double T
def move(src, dest)
Definition: eostools.py:511