1 #ifndef __WORKQUEUE_H__
2 #define __WORKQUEUE_H__ 1
4 #include <boost/thread.hpp>
5 #include <boost/shared_ptr.hpp>
14 struct interrupted_error : public virtual std::exception { };
19 virtual ~WorkUnit() {};
20 virtual void run() = 0;
27 WorkQueue(int thread_count);
31 shared_ptr<WorkUnit> get();
32 void put(shared_ptr<WorkUnit> work_unit);
41 Worker(WorkQueue* queue);
51 condition_variable _queue_non_empty;
52 queue<shared_ptr<WorkUnit> > _queue;
53 thread_group _threads;
54 volatile bool _running;
57 class TaskNotification
63 void completeTask(bool success = true);
65 void waitForComplete();
73 condition_variable _cond;