I use MS Visual Studio 2010, C++,PPL library for parallel calculations and Qt library.

Concurrency::parallel_for (size_t(0), m_Engines.size(), [&](size_t i)
{
    for (size_t j = 1;j <= m_Iterations;j++)
    {
        Compute(i);//some time-cosuming thing           
    }
});

Let's imagine we've got 3 independent engines with m_Iterations for each one. The progress bar for each engine will look like:

progress 1: ||||||||

progress 2: |||||

progress 3: |||||||||||

And I wanna have the single progressbar (instead of the shown above) which shows the backward progressbar (which shows minimal value among them):

total progress: |||||

Let us assume that we have QProgressBar * pProgressbar, CoreApplication::processEvents() "code snippets". How should I modify the code in order to implement the idea of a single progress bar for the inner loop using Concurrency Runtime techniques.

有帮助吗?

解决方案

In order to show the minimal time, you can use QWaitCondition in side the function or you can write separate function to notify one m_Iterations finish. Lets assume , currently you are executing 3 parallel calculation engine , write QWaitCondition to signal other iterations do their jobs.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top