19 #include <boost/bind.hpp> 20 #include <boost/thread/mutex.hpp> 51 print(
" task_1()\n" );
57 print(
" task_2()\n" );
68 print(
" looped_task()\n" );
74 print(
" task_int_23()\n" );
80 print(
" task_int_1()\n" );
94 int main(
int,
char*
const[] )
96 print(
"\nWelcome to the threadpool tutorial!\n" );
98 print(
"\n**************************************\n" );
99 print(
"Section 1: Quick Start\n" );
103 print(
" Create a new thread pool\n" );
122 print(
"\n**************************************\n" );
123 print(
"Section 1: Futures\n" );
149 int value = res.
get() + res2.
get();
161 print(
"\n**************************************\n" );
162 print(
"Section 2: Controlling scheduling\n" );
167 print(
" Add tasks (using the pool's schedule function)\n" );
174 print(
" Add some threads ...\n" );
177 print(
" Wait until all tasks are finished ...\n" );
179 print(
" Tasks finished!\n" );
183 print(
"\n**************************************\n" );
184 print(
"Section 3: Prioritized Tasks\n" );
188 print(
" Add prioritized tasks ...\n" );
195 print(
" Thread added\n" );
198 print(
" Wait until all tasks are finished ...\n" );
200 print(
" Tasks finished!\n" );
205 print(
"\n**************************************\n" );
206 print(
"Section 5: Advanced thread pool instantiation\n" );
222 print(
" Tasks finished!\n" );
225 print(
"\n**************************************\n" );
226 print(
"Tutorial finished!\n" );
229 print(
"\n**************************************\n" );
230 print(
"Section Compile Tests\n" );
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 ...
void task_with_parameter(int value)
bool schedule(task_type const &task)
Schedules a task for asynchronous execution.
bool empty() const
Indicates that there are no tasks pending.
size_t pending() const
Returns the number of tasks which are ready for execution.
int main(int, char *const [])
disable_if< is_void< typename result_of< Function() >::type >, future< typename result_of< Function() >::type >>::type schedule(Pool &pool, const Function &task)
size_controller_type size_controller()
Gets the size controller which manages the number of threads in the pool.
boost::mutex m_io_monitor
Prioritized task function object.