21 #include <boost/thread/mutex.hpp> 22 #include <boost/bind.hpp> 76 print(
" looped_task()\n");
83 print(
" task_int_23()\n");
89 print(
" task_int_1()\n");
107 int main (
int ,
char *
const [])
109 print(
"\nWelcome to the threadpool tutorial!\n");
111 print(
"\n**************************************\n");
112 print(
"Section 1: Quick Start\n");
116 print(
" Create a new thread pool\n");
135 print(
"\n**************************************\n");
136 print(
"Section 1: Futures\n");
163 int value = res.
get() + res2.
get();
177 print(
"\n**************************************\n");
178 print(
"Section 2: Controlling scheduling\n");
183 print(
" Add tasks (using the pool's schedule function)\n");
190 print(
" Add some threads ...\n");
193 print(
" Wait until all tasks are finished ...\n");
195 print(
" Tasks finished!\n");
201 print(
"\n**************************************\n");
202 print(
"Section 3: Prioritized Tasks\n");
207 print(
" Add prioritized tasks ...\n");
214 print(
" Thread added\n");
217 print(
" Wait until all tasks are finished ...\n");
219 print(
" Tasks finished!\n");
225 print(
"\n**************************************\n");
226 print(
"Section 5: Advanced thread pool instantiation\n");
242 print(
" Tasks finished!\n");
247 print(
"\n**************************************\n");
248 print(
"Tutorial finished!\n");
253 print(
"\n**************************************\n");
254 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.