Boost logo

Boost Users :

Subject: Re: [Boost-users] Create A Boost Thread for each HW Thread?
From: Scott McMurray ([hidden])
Date: 2011-06-09 22:19:24

On Thu, Jun 9, 2011 at 18:13, Brad <boost_at_[hidden]> wrote:
> 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():

~ 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 );

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at