00001 #ifndef PN_ASYNC_WORKER_H
00002 #define PN_ASYNC_WORKER_H 1
00003
00004 #include <stdlib.h>
00005
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00160 namespace async
00161 {
00162
00163
00164
00166
00169
00172
00174
00176 extern void Queue(const class workload_t* const instance) ;
00177
00184 extern bool GetResults() ;
00185
00188 extern size_t PendingResults() ;
00189
00190 class workload_t
00191 {
00192 public:
00193
00194 workload_t() {}
00195
00196 public:
00198
00202
00204
00205 void Queue() const { async::Queue(this) ; }
00206
00207 public:
00210 virtual void Work() = 0 ;
00211
00212 public:
00217 virtual void Result() {}
00218
00219 public:
00222 virtual bool HasResults() const { return false ; }
00223
00224 public:
00227 virtual void Destroy() const { delete const_cast<workload_t*>(this) ; }
00228 } ;
00229
00233
00236
00238
00243
00244 class dispatch_t : public workload_t
00245 {
00246 public:
00248 dispatch_t() : workload_t() {}
00249 } ;
00250
00256
00260
00264
00268
00273
00274 class worker_t : public workload_t
00275 {
00276 public:
00278 worker_t() : workload_t() {}
00279
00280 public:
00281 virtual bool HasResults() const { return true ; }
00282 } ;
00283
00289
00293
00297
00301
00306
00307 class static_worker_t : public workload_t
00308 {
00309 public:
00311 static_worker_t() : workload_t() {}
00312
00313 public:
00314 virtual bool HasResults() const { return true ; }
00315
00316 public:
00317 virtual void Destroy() const { }
00318 } ;
00319
00320 }
00321
00322 #endif // PN_ASYNC_WORKER_H
00323