libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
thread_work_closure_impl.hpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright © 2004 by J.M.McGuiness, coder@hussar.me.uk
3 **
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Lesser General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2.1 of the License, or (at your option) any later version.
8 **
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public
15 ** License along with this library; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 namespace jmmcg { namespace LIBJMMCG_VER_NAMESPACE { namespace ppd { namespace private_ { namespace closure {
20 
21 // Implementation details..... Don't look below here!!! ;)
22 
23  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() noexcept(NoExcept), class CFG>
24  inline __stdcall
27  }
28 
29  // If you have a compile-time error here regarding matching operator<(), then it is possible that the type you are attempting to transfer into the thread_pool does not have an operator<() member declared, because you might be using a pool_traits::prioritised_queue in the thread_pool, which requires it.
30  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() noexcept(NoExcept), class CFG>
31  inline bool __fastcall
32  closure_void_static<InpWk, NoExcept, Proc, CFG>::operator<(const closure_void_static &tw) const noexcept(true) {
33  return static_cast<argument_type const &>(*this)<static_cast<argument_type const &>(tw);
34  }
35 
36  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() noexcept(NoExcept), class CFG>
37  inline bool __fastcall
38  closure_void_static<InpWk, NoExcept, Proc, CFG>::operator==(const closure_void_static &tw) const noexcept(true) {
39  return !(*this<tw) && !(tw<*this);
40  }
41 
42  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() noexcept(NoExcept), class CFG>
43  inline const typename closure_void_static<InpWk, NoExcept, Proc, CFG>::argument_type & __fastcall
44  closure_void_static<InpWk, NoExcept, Proc, CFG>::input() const noexcept(true) {
45  return static_cast<argument_type const &>(*this);
46  }
47 
48  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() noexcept(NoExcept), class CFG>
49  inline typename closure_void_static<InpWk, NoExcept, Proc, CFG>::argument_type & __fastcall
50  closure_void_static<InpWk, NoExcept, Proc, CFG>::input() noexcept(true) {
51  return static_cast<argument_type &>(*this);
52  }
53 
54 #pragma GCC diagnostic push
55 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
56 
57  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() noexcept(NoExcept), class CFG>
58  inline void __fastcall
60  (static_cast<argument_type &>(*this).*Proc)();
61  }
62 
63 #pragma GCC diagnostic pop
64 
65  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() const noexcept(NoExcept), class CFG>
66  inline __stdcall
69  }
70 
71  // If you have a compile-time error here regarding matching operator<(), then it is possible that the type you are attempting to transfer into the thread_pool does not have an operator<() member declared, because you might be using a pool_traits::prioritised_queue in the thread_pool, which requires it.
72  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() const noexcept(NoExcept), class CFG>
73  inline bool __fastcall
75  return static_cast<argument_type const &>(*this)<static_cast<argument_type const &>(tw);
76  }
77 
78  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() const noexcept(NoExcept), class CFG>
79  inline bool __fastcall
81  return !(*this<tw) && !(tw<*this);
82  }
83 
84  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() const noexcept(NoExcept), class CFG>
85  inline const typename closure_void_static_const<InpWk, NoExcept, Proc, CFG>::argument_type & __fastcall
86  closure_void_static_const<InpWk, NoExcept, Proc, CFG>::input() const noexcept(true) {
87  return static_cast<argument_type const &>(*this);
88  }
89 
90  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() const noexcept(NoExcept), class CFG>
91  inline typename closure_void_static_const<InpWk, NoExcept, Proc, CFG>::argument_type & __fastcall
93  return static_cast<argument_type &>(*this);
94  }
95 
96 #pragma GCC diagnostic push
97 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
98 
99  template<class InpWk, bool NoExcept, void (__fastcall InpWk::*Proc)() const noexcept(NoExcept), class CFG>
100  inline void __fastcall
102  (static_cast<argument_type const &>(*this).*Proc)();
103  }
104 
105 #pragma GCC diagnostic pop
106 
107  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) noexcept(NoExcept), class CFG>
108  inline __stdcall
111  }
112 
113  // If you have a compile-time error here regarding matching operator<(), then it is possible that the type you are attempting to transfer into the thread_pool does not have an operator<() member declared, because you might be using a pool_traits::prioritised_queue in the thread_pool, which requires it.
114  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) noexcept(NoExcept), class CFG>
115  inline bool __fastcall
116  closure_static<InpWk, Res, NoExcept, Proc, CFG>::operator<(const closure_static &tw) const noexcept(true) {
117  return static_cast<argument_type const &>(*this)<static_cast<argument_type const &>(tw);
118  }
119 
120  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) noexcept(NoExcept), class CFG>
121  inline bool __fastcall
122  closure_static<InpWk, Res, NoExcept, Proc, CFG>::operator==(const closure_static &tw) const noexcept(true) {
123  return !(*this<tw) && !(tw<*this);
124  }
125 
126  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) noexcept(NoExcept), class CFG>
127  inline const typename closure_static<InpWk, Res, NoExcept, Proc, CFG>::argument_type & __fastcall
128  closure_static<InpWk, Res, NoExcept, Proc, CFG>::input() const noexcept(true) {
129  return static_cast<argument_type const &>(*this);
130  }
131 
132  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) noexcept(NoExcept), class CFG>
133  inline typename closure_static<InpWk, Res, NoExcept, Proc, CFG>::argument_type & __fastcall
134  closure_static<InpWk, Res, NoExcept, Proc, CFG>::input() noexcept(true) {
135  return static_cast<argument_type &>(*this);
136  }
137 
138 #pragma GCC diagnostic push
139 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
140 
141  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) noexcept(NoExcept), class CFG>
142  inline void __fastcall
144  (static_cast<argument_type &>(*this).*Proc)(result_);
145  }
146 
147 #pragma GCC diagnostic pop
148 
149  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) noexcept(NoExcept), class CFG>
150  inline const typename closure_static<InpWk, Res, NoExcept, Proc, CFG>::result_type & __fastcall
151  closure_static<InpWk, Res, NoExcept, Proc, CFG>::get_results() const noexcept(false) {
152  return result_;
153  }
154 
155  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) noexcept(NoExcept), class CFG>
156  inline typename closure_static<InpWk, Res, NoExcept, Proc, CFG>::result_type & __fastcall
157  closure_static<InpWk, Res, NoExcept, Proc, CFG>::get_results() noexcept(false) {
158  return result_;
159  }
160 
161  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) noexcept(NoExcept), class CFG>
162  inline __stdcall
165  }
166 
167  // If you have a compile-time error here regarding matching operator<(), then it is possible that the type you are attempting to transfer into the thread_pool does not have an operator<() member declared, because you might be using a pool_traits::prioritised_queue in the thread_pool, which requires it.
168  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) noexcept(NoExcept), class CFG>
169  inline bool __fastcall
170  closure_static_cfg<InpWk, Res, CFGP, NoExcept, Proc, CFG>::operator<(const closure_static_cfg &tw) const noexcept(true) {
171  return static_cast<argument_type const &>(*this)<static_cast<argument_type const &>(tw);
172  }
173 
174  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) noexcept(NoExcept), class CFG>
175  inline bool __fastcall
176  closure_static_cfg<InpWk, Res, CFGP, NoExcept, Proc, CFG>::operator==(const closure_static_cfg &tw) const noexcept(true) {
177  return !(*this<tw) && !(tw<*this);
178  }
179 
180  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) noexcept(NoExcept), class CFG>
181  inline const typename closure_static_cfg<InpWk, Res, CFGP, NoExcept, Proc, CFG>::argument_type & __fastcall
182  closure_static_cfg<InpWk, Res, CFGP, NoExcept, Proc, CFG>::input() const noexcept(true) {
183  return static_cast<argument_type const &>(*this);
184  }
185 
186  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) noexcept(NoExcept), class CFG>
187  inline typename closure_static_cfg<InpWk, Res, CFGP, NoExcept, Proc, CFG>::argument_type & __fastcall
188  closure_static_cfg<InpWk, Res, CFGP, NoExcept, Proc, CFG>::input() noexcept(true) {
189  return static_cast<argument_type &>(*this);
190  }
191 
192 #pragma GCC diagnostic push
193 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
194 
195  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) noexcept(NoExcept), class CFG>
196  inline void __fastcall
198  (static_cast<argument_type &>(*this).*Proc)(result_, cfg_params);
199  }
200 
201 #pragma GCC diagnostic pop
202 
203  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) noexcept(NoExcept), class CFG>
204  inline const typename closure_static_cfg<InpWk, Res, CFGP, NoExcept, Proc, CFG>::result_type & __fastcall
205  closure_static_cfg<InpWk, Res, CFGP, NoExcept, Proc, CFG>::get_results() const noexcept(false) {
206  return result_;
207  }
208 
209  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) noexcept(NoExcept), class CFG>
210  inline typename closure_static_cfg<InpWk, Res, CFGP, NoExcept, Proc, CFG>::result_type & __fastcall
212  return result_;
213  }
214 
215  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) const noexcept(NoExcept), class CFG>
216  inline __stdcall
219  }
220 
221  // If you have a compile-time error here regarding matching operator<(), then it is possible that the type you are attempting to transfer into the thread_pool does not have an operator<() member declared, because you might be using a pool_traits::prioritised_queue in the thread_pool, which requires it.
222  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) const noexcept(NoExcept), class CFG>
223  inline bool __fastcall
224  closure_static_const<InpWk, Res, NoExcept, Proc, CFG>::operator<(const closure_static_const &tw) const noexcept(true) {
225  return static_cast<argument_type const &>(*this)<static_cast<argument_type const &>(tw);
226  }
227 
228  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) const noexcept(NoExcept), class CFG>
229  inline bool __fastcall
231  return !(*this<tw) && !(tw<*this);
232  }
233 
234  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) const noexcept(NoExcept), class CFG>
235  inline const typename closure_static_const<InpWk, Res, NoExcept, Proc, CFG>::argument_type & __fastcall
236  closure_static_const<InpWk, Res, NoExcept, Proc, CFG>::input() const noexcept(true) {
237  return static_cast<argument_type const &>(*this);
238  }
239 
240  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) const noexcept(NoExcept), class CFG>
241  inline typename closure_static_const<InpWk, Res, NoExcept, Proc, CFG>::argument_type & __fastcall
243  return static_cast<argument_type &>(*this);
244  }
245 
246 #pragma GCC diagnostic push
247 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
248 
249  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) const noexcept(NoExcept), class CFG>
250  inline void __fastcall
252  (static_cast<argument_type const &>(*this).*Proc)(result_);
253  }
254 
255 #pragma GCC diagnostic pop
256 
257  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) const noexcept(NoExcept), class CFG>
258  inline const typename closure_static_const<InpWk, Res, NoExcept, Proc, CFG>::result_type & __fastcall
259  closure_static_const<InpWk, Res, NoExcept, Proc, CFG>::get_results() const noexcept(true) {
260  return result_;
261  }
262 
263  template<class InpWk, class Res, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &) const noexcept(NoExcept), class CFG>
264  inline typename closure_static_const<InpWk, Res, NoExcept, Proc, CFG>::result_type & __fastcall
266  return result_;
267  }
268 
269  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) const noexcept(NoExcept), class CFG>
270  inline __stdcall
273  }
274 
275  // If you have a compile-time error here regarding matching operator<(), then it is possible that the type you are attempting to transfer into the thread_pool does not have an operator<() member declared, because you might be using a pool_traits::prioritised_queue in the thread_pool, which requires it.
276  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) const noexcept(NoExcept), class CFG>
277  inline bool __fastcall
279  return static_cast<argument_type const &>(*this)<static_cast<argument_type const &>(tw);
280  }
281 
282  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) const noexcept(NoExcept), class CFG>
283  inline bool __fastcall
285  return !(*this<tw) && !(tw<*this);
286  }
287 
288  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) const noexcept(NoExcept), class CFG>
289  inline const typename closure_static_cfg_const<InpWk, Res, CFGP, NoExcept, Proc, CFG>::argument_type & __fastcall
290  closure_static_cfg_const<InpWk, Res, CFGP, NoExcept, Proc, CFG>::input() const noexcept(true) {
291  return static_cast<argument_type const &>(*this);
292  }
293 
294  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) const noexcept(NoExcept), class CFG>
295  inline typename closure_static_cfg_const<InpWk, Res, CFGP, NoExcept, Proc, CFG>::argument_type & __fastcall
297  return static_cast<argument_type &>(*this);
298  }
299 
300 #pragma GCC diagnostic push
301 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
302 
303  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) const noexcept(NoExcept), class CFG>
304  inline void __fastcall
306  (static_cast<argument_type const &>(*this).*Proc)(result_, cfg_params);
307  }
308 
309 #pragma GCC diagnostic pop
310 
311  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) const noexcept(NoExcept), class CFG>
312  inline const typename closure_static_cfg_const<InpWk, Res, CFGP, NoExcept, Proc, CFG>::result_type & __fastcall
314  return result_;
315  }
316 
317  template<class InpWk, class Res, class CFGP, bool NoExcept, void (__fastcall InpWk::*Proc)(Res &, CFGP const &) const noexcept(NoExcept), class CFG>
318  inline typename closure_static_cfg_const<InpWk, Res, CFGP, NoExcept, Proc, CFG>::result_type & __fastcall
320  return result_;
321  }
322 
323 } } } } }