Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2008-05-27 17:01:56


I just discovered that while none of my standard containers are
"move-aware" in the way needed by boost::thread, I can use boost::array
to store threads by simply move-assigning new threads into the elements
it contains:

   boost::array<boost::thread, 100> thread_q;

   for (int i = 0; i < 100; ++i)
       thread_q[i] = boost::thread( some_function );

it ain't perfect, but given that the number of cores on any real machine
is limited these days, you can do a lot with a fixed-size array of
thread. Pretty cool; it sure beats using shared_ptr.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk