00001 #line 1326 "./lpsrc/flx_pthread.pak"
00002 #ifndef __WORKER_FIFO__
00003 #define __WORKER_FIFO__
00004 #include <flx_pthread_config.hpp>
00005 #include "pthread_thread.hpp"
00006 #include "pthread_mutex.hpp"
00007 #include "pthread_sleep_queue.hpp"
00008
00009 namespace flx { namespace pthread {
00010
00011
00012 class PTHREAD_EXTERN worker_task
00013 {
00014 public:
00015 virtual ~worker_task() {}
00016
00017
00018 virtual void doit() = 0;
00019
00020
00021
00022 virtual void finished() = 0;
00023 };
00024
00025
00026 class PTHREAD_EXTERN worker_fifo
00027 {
00028 sleep_queue_t fifo;
00029 int nthreads;
00030
00031 static void* thread_start(void*);
00032 bool thread_loop_body();
00033 void stop_worker_thread();
00034 void start_worker_thread();
00035
00036 public:
00037 worker_fifo(int n, int m);
00038 ~worker_fifo();
00039 void add_worker_task(worker_task* task);
00040 int get_nthreads()const;
00041 void set_nthreads(int);
00042 };
00043
00044 }}
00045 #endif // __WORKER_FIFO__
00046