All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FuncWrapper.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_UTIL_THREADPOOL_FUNCWRAPPER_H_
23 #define _BLAZE_UTIL_THREADPOOL_FUNCWRAPPER_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
30 #include <boost/type_traits.hpp>
31 #include <boost/utility/result_of.hpp>
34 
35 
36 namespace blaze {
37 
38 namespace threadpool {
39 
40 //=================================================================================================
41 //
42 // CLASS DEFINITION
43 //
44 //=================================================================================================
45 
46 //*************************************************************************************************
64 template< typename Callable > // Type of the function/functor
65 class FuncWrapper : public Task
66 {
67  public:
68  //**Constructor*********************************************************************************
71  explicit inline FuncWrapper( Callable func );
73  //**********************************************************************************************
74 
75  //**Destructor**********************************************************************************
78  virtual ~FuncWrapper();
80  //**********************************************************************************************
81 
82  //**Execution functions*************************************************************************
85  virtual void run();
87  //**********************************************************************************************
88 
89  private:
90  //**Member variables****************************************************************************
93  Callable func_;
94 
95  //**********************************************************************************************
96 
97  //**Compile time checks*************************************************************************
99  BLAZE_STATIC_ASSERT( boost::function_traits<Callable()>::arity == 0 );
100  BLAZE_STATIC_ASSERT( boost::is_void< typename boost::result_of<Callable()>::type >::value );
102  //**********************************************************************************************
103 };
104 //*************************************************************************************************
105 
106 
107 
108 
109 //=================================================================================================
110 //
111 // CONSTRUCTOR
112 //
113 //=================================================================================================
114 
115 //*************************************************************************************************
120 template< typename Callable > // Type of the function/functor
121 inline FuncWrapper<Callable>::FuncWrapper( Callable func )
122  : func_( func ) // The wrapped function/functor
123 {}
124 //*************************************************************************************************
125 
126 
127 
128 
129 //=================================================================================================
130 //
131 // DESTRUCTOR
132 //
133 //=================================================================================================
134 
135 //*************************************************************************************************
138 template< typename Callable > // Type of the function/functor
140 {}
141 //*************************************************************************************************
142 
143 
144 
145 
146 //=================================================================================================
147 //
148 // EXECUTION FUNCTIONS
149 //
150 //=================================================================================================
151 
152 //*************************************************************************************************
157 template< typename Callable > // Type of the function/functor
159 {
160  func_();
161 }
162 //*************************************************************************************************
163 
164 } // namespace threadpool
165 
166 } // namespace blaze
167 
168 #endif