int donePixels = 0;
int activeThreads = 0;
do
{
while(activeThreads < numThreads)
{
threads.push_back(std::thread(drawPixel, donePixels + activeThreads, cam, world, &p));
activeThreads++;
}
for (auto &t : threads)
{
if(t.joinable())
{
activeThreads--;
donePixels++;
t.join();
}
}
std::cout << donePixels * 100 / (nx * ny) << "% done" << std::endl;
} while(donePixels < nx * ny)
I intend to change this so that each thread does one row of pixels.