CMS 3D CMS Logo

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

◆ ThreadSafeFunctor() [1/2]

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_

◆ ThreadSafeFunctor() [2/2]

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(src, dest)
Definition: eostools.py:511

Member Function Documentation

◆ operator()()

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

◆ functor_

template<class Functor>
const Functor ThreadSafeFunctor< Functor >::functor_
private

◆ mutex_

template<class Functor>
std::mutex ThreadSafeFunctor< Functor >::mutex_
mutableprivate