00001 #include <boost/asio.hpp>
00002 #include <boost/bind.hpp>
00003 #include <boost/thread.hpp>
00004 #include <boost/scoped_ptr.hpp>
00005 #include <boost/shared_ptr.hpp>
00006
00007 #include <iostream>
00008 #include <vector>
00009 #include <string>
00010 #include "moses/TranslationModel/UG/generic/threading/ug_thread_pool.h"
00011 using namespace std;
00012
00013 class hello
00014 {
00015 size_t n;
00016 public:
00017 hello(size_t const x) : n(x) { }
00018 void operator()() { cout << "hello #" << n << endl; }
00019 };
00020
00021
00022 int main()
00023 {
00024 ug::ThreadPool T(10);
00025 vector<boost::shared_ptr<hello> > jobs;
00026 for (size_t i = 0; i < 20; ++i)
00027 {
00028 boost::shared_ptr<hello> j(new hello(i));
00029 jobs.push_back(j);
00030 T.add(*j);
00031 }
00032 }