All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
quickstart.cpp
Go to the documentation of this file.
1 
16 #include <iostream>
17 
18 #include <boost/threadpool.hpp>
19 
20 using namespace std;
21 using namespace boost::threadpool;
22 
23 // Some example tasks
24 void first_task()
25 {
26  cout << "first task is running\n" ;
27 }
28 
30 {
31  cout << "second task is running\n" ;
32 }
33 
34 int main(int argc,char *argv[])
35 {
36  // Create fifo thread pool container with two threads.
37  pool tp(2);
38 
39  // Add some tasks to the pool.
40  tp.schedule(&first_task);
41  tp.schedule(&second_task);
42 
43  // Wait until all tasks are finished.
44  tp.wait();
45 
46  // Now all tasks are finished!
47  return(0);
48 }
49 
50 
void wait(size_t task_threshold=0) const
The current thread of execution is blocked until the sum of all active and pending tasks is equal or ...
Definition: pool.hpp:176
void first_task()
Definition: quickstart.cpp:24
list argv
Definition: gaudirun.py:227
int main(int argc, char *argv[])
Definition: quickstart.cpp:34
STL namespace.
bool schedule(task_type const &task)
Schedules a task for asynchronous execution.
Definition: pool.hpp:130
void second_task()
Definition: quickstart.cpp:29
Main include.