10 Jun
2011
10 Jun
'11
2:19 a.m.
On Thu, Jun 9, 2011 at 18:13, Brad
What's the proper way to start a boost thread for each hardware thread available? I can do this... but it is clunky and does not scale (especially when there are lots of cores):
Sound like you want a thread_group, to which you can call create_thread() or add_thread() in a loop then join_all(): http://www.boost.org/doc/html/thread/thread_management.html#thread.thread_ma... ~ Scott Or you could always do silly things with recursion: void foo(int n = boost::thread::hardware_concurrency()) { if (n < 1) return; boost::thread bar( task, thread_data, St ); foo(n-1); bar.join(); }