CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
ThreadSafeFunctor< Functor > Class Template Reference

#include <ThreadSafeFunctor.h>

Public Member Functions

template<typename... Params>
std::invoke_result_t< Functor,
Params...> 
operator() (Params &&...params) const
 
template<typename... Params>
 ThreadSafeFunctor (Params &&...params)
 
 ThreadSafeFunctor (ThreadSafeFunctor &&other) noexcept
 

Private Attributes

const Functor functor_
 
std::mutex mutex_
 

Detailed Description

template<class Functor>
class ThreadSafeFunctor< Functor >

Definition at line 12 of file ThreadSafeFunctor.h.

Constructor & Destructor Documentation

template<class Functor>
template<typename... Params>
ThreadSafeFunctor< Functor >::ThreadSafeFunctor ( Params &&...  params)
inline

Definition at line 15 of file ThreadSafeFunctor.h.

15 : functor_{std::forward<Params>(params)...} {}
const Functor functor_
template<class Functor>
ThreadSafeFunctor< Functor >::ThreadSafeFunctor ( ThreadSafeFunctor< Functor > &&  other)
inlinenoexcept

Definition at line 17 of file ThreadSafeFunctor.h.

17 : functor_(std::move(other.functor_)) {}
const Functor functor_
def move
Definition: eostools.py:511

Member Function Documentation

template<class Functor>
template<typename... Params>
std::invoke_result_t<Functor, Params...> ThreadSafeFunctor< Functor >::operator() ( Params &&...  params) const
inline

Definition at line 20 of file ThreadSafeFunctor.h.

20  {
21  std::lock_guard<std::mutex> guard(mutex_);
22  return functor_(std::forward<Params>(params)...);
23  }
const Functor functor_

Member Data Documentation

template<class Functor>
const Functor ThreadSafeFunctor< Functor >::functor_
private
template<class Functor>
std::mutex ThreadSafeFunctor< Functor >::mutex_
mutableprivate