On Mon, Jul 26, 2010 at 8:41 AM, Eric J. Holtman <eric@holtmans.com> wrote:
On 7/26/2010 9:37 AM, Internet Retard wrote:


All at once? What if I have millions of tasks rather than a few? I want to be working on 2 tasks all the time. If my queue is not empty, then as a thread ends, it sees there are more tasks in the queue and gets one.


You only launch *two* tasks.   They keep going back to the
queue to get new work when they finished their current item.


You might want to look at the threadpool project:
  http://threadpool.sourceforge.net/
This is built on boost::thread and has a very nice implementation for queuing work for threads.  It has various types of queues (priority, fifo, etc).