vSMC
vSMC: Scalable Monte Carlo
Public Member Functions | List of all members
vsmc::DispatchFunction< T > Class Template Reference

Wrap a callable object into a dispatch_function_t type pointer. More...

#include <vsmc/gcd/dispatch_function.hpp>

Public Member Functions

 DispatchFunction (const T &work)
 
 DispatchFunction (T &&work) noexcept
 
void * context ()
 
::dispatch_function_t function () const
 

Detailed Description

template<typename T>
class vsmc::DispatchFunction< T >

Wrap a callable object into a dispatch_function_t type pointer.

It is important that this object live at least after the completion of the work. This is a thin wrapper around a regular C++ callable object (including lambda expressions) that make it easier to interface them with GCD. The memory management issue is the same as using raw GCD interface with a context variable, which shall not be destroyed before the execution of the function finishes. The original object does not need to exist after the creation of DispatchFunction.

Definition at line 52 of file dispatch_function.hpp.

Constructor & Destructor Documentation

template<typename T>
vsmc::DispatchFunction< T >::DispatchFunction ( const T &  work)
inline

Definition at line 56 of file dispatch_function.hpp.

template<typename T>
vsmc::DispatchFunction< T >::DispatchFunction ( T &&  work)
inlinenoexcept

Definition at line 59 of file dispatch_function.hpp.

Member Function Documentation

template<typename T>
void* vsmc::DispatchFunction< T >::context ( )
inline

Definition at line 62 of file dispatch_function.hpp.

template<typename T>
::dispatch_function_t vsmc::DispatchFunction< T >::function ( ) const
inline

Definition at line 64 of file dispatch_function.hpp.