File size: 642 Bytes
158b61b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>

#include <iostream>
#include <vector>
#include <string>
#include "moses/TranslationModel/UG/generic/threading/ug_thread_pool.h"
using namespace std;

class hello
{
  size_t n;
public:
  hello(size_t const x) : n(x) { }
  void operator()() { cout << "hello #" << n << endl; }
};


int main()
{
  ug::ThreadPool T(10);
  vector<boost::shared_ptr<hello> > jobs;
  for (size_t i = 0; i < 20; ++i)
    {
      boost::shared_ptr<hello> j(new hello(i));
      jobs.push_back(j);
      T.add(*j);
    }
}