00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef INCLUDED_GRUEL_THREAD_GROUP_H
00016 #define INCLUDED_GRUEL_THREAD_GROUP_H
00017
00018 #include <gruel/thread.h>
00019 #include <boost/utility.hpp>
00020 #include <boost/thread/shared_mutex.hpp>
00021 #include <boost/function.hpp>
00022
00023 namespace gruel
00024 {
00025 class thread_group : public boost::noncopyable
00026 {
00027 public:
00028 thread_group();
00029 ~thread_group();
00030
00031 boost::thread* create_thread(const boost::function0<void>& threadfunc);
00032 void add_thread(boost::thread* thrd);
00033 void remove_thread(boost::thread* thrd);
00034 void join_all();
00035 void interrupt_all();
00036 size_t size() const;
00037
00038 private:
00039 std::list<boost::thread*> m_threads;
00040 mutable boost::shared_mutex m_mutex;
00041 };
00042 }
00043
00044 #endif