
Le 08/12/11 17:30, Kelvin Chung a écrit :
Now suppose that there is a point where I have a list of Tasks and I want to have them executed concurrently. To do so, I've leveraged Boost.Asio to create a thread pool task queue construct (via boost::asio::io_service). The next step beyond that is that I want to evaluate each of the tasks in CompositeTasks in parallel. I have a few questions about this:
* One idea is to make a separate task thread for each CompositeTask. I'm under the impression that there is an absolute limit to the number of threads that I can make, which is determined by boost::thread::hardware_concurrency(). Is this true?
If you want real parallelism the answer is yes. If you want concurrent threads the number is limited by the memory you have.
If so, if the main Task queue has that many threads, would making a second task queue fail because it can't get more? * If I keep to one task queue (ie. throw all the Tasks in the CompositeTask to the main Task queue), then the possiblity exists of some kind of starvation (eg. the queue is full of CompositeTasks, and they are all blocking due to dependencies on Tasks in the queue). Is there a way to prioritize Tasks in the queue so that this doesn't happen?
Boost.Task (which is not yet in Boost) try to answer the questions you make (http://gitorious.org/boost-dev/boost-dev/trees/task-dev/boost). Best, Vicente