The Gaudi Framework  v29r0 (ff2e7097)
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() { cout << "first task is running\n"; }
25 
26 void second_task() { cout << "second task is running\n"; }
27 
28 int main( int argc, char* argv[] )
29 {
30  // Create fifo thread pool container with two threads.
31  pool tp( 2 );
32 
33  // Add some tasks to the pool.
34  tp.schedule( &first_task );
35  tp.schedule( &second_task );
36 
37  // Wait until all tasks are finished.
38  tp.wait();
39 
40  // Now all tasks are finished!
41  return ( 0 );
42 }
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:235
int main(int argc, char *argv[])
Definition: quickstart.cpp:28
STL namespace.
bool schedule(task_type const &task)
Schedules a task for asynchronous execution.
Definition: pool.hpp:130
void second_task()
Definition: quickstart.cpp:26
Main include.