s
Nana C++ Library An open-source C++ framework project The Programmer's Guide |
||||||||||||
nana::threads::pool Description A thread pool manages a group threads for a large number of tasks processing. Model of None Public base classes None Members
File nana/threads/pool.hpp Notes 1, The signal()/wait_for_signal() provide a method to wait for tasks to finish. void foo() {} void foo2() { nana::system::sleep(1000); std::cout<<"This is foo2"<<std::endl; } int main() { nana::threads::pool pool; for(int i = 0; i < 10; ++i) pool.push(foo); pool.signal(); //Make a signal and the signal will be triggered when the //tasks which are pushed before it are finished. pool.push(foo2); pool.wait_for_signal(); //Wait until the signal is triggered. The wait might be finished //before finish of foo2, because the signal is made before pushing foo2. } See also pool_pusher, A Method to prevent UI from blocking while busy. Move to The Nana Programmer's Guide Main Page |
||||||||||||