OSDN Git Service

thread_pool追加
authortakamaru <takamaru@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Thu, 25 Dec 2008 10:16:37 +0000 (10:16 +0000)
committertakamaru <takamaru@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Thu, 25 Dec 2008 10:16:37 +0000 (10:16 +0000)
git-svn-id: http://10.144.169.20/repos/um/branches/l7vsd-3.x-shamshel@5517 1ed66053-1c2d-0410-8867-f7571e6e31d3

include/thread_pool.h [new file with mode: 0644]

diff --git a/include/thread_pool.h b/include/thread_pool.h
new file mode 100644 (file)
index 0000000..2792b1b
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef __THREAD_POOL_H__
+#define __THREAD_POOL_H__
+
+#include <boost/thread.hpp>
+
+class thread_pool {
+public:
+       template <typename F>
+       void schedule(F threadfunc) {
+               tg_->create_thread(threadfunc);
+       }
+
+       void wait() {
+               tg_->join_all();
+       }
+
+       thread_pool() :
+               tg_(new boost::thread_group) {}
+
+
+protected:
+       boost::shared_ptr<boost::thread_group> tg_;
+};
+
+#endif //__THREAD_POOL_H__