blob: 858573a0a8f87a3209aa9b510a3e74d44f65276f (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*! \file
* \brief Quick start example.
*
* This is a very simple example which can be used to configure the threadpool environment on your system.
*
* Copyright (c) 2005-2006 Philipp Henkel
*
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* http://threadpool.sourceforge.net
*
*/
#include <iostream>
#include <boost/threadpool.hpp>
using namespace std;
using namespace boost::threadpool;
// Some example tasks
void first_task()
{
cout << "first task is running\n" ;
}
void second_task()
{
cout << "second task is running\n" ;
}
int main(int argc,char *argv[])
{
// Create fifo thread pool container with two threads.
pool tp(2);
// Add some tasks to the pool.
tp.schedule(&first_task);
tp.schedule(&second_task);
// Wait until all tasks are finished.
tp.wait();
// Now all tasks are finished!
return(0);
}
|