Experimental: remove use of mutex when threaded

In theory, it seems that each pixel is only written to once, regardless
of how many threads there are. Theoretically, this means that locks are
not required.
This commit is contained in:
Stephen Seo 2021-08-24 18:30:15 +09:00
parent 075aab2a57
commit 13bf59dcc8

View file

@ -429,7 +429,7 @@ Ex02::RT::Image Ex02::RT::renderColorsWithSpheres(unsigned int outputWidth,
}
} else {
std::vector<std::thread> threads;
std::mutex mutex;
// std::mutex mutex;
unsigned int range = outputHeight / threadCount;
for (unsigned int threadIdx = 0; threadIdx < threadCount; ++threadIdx) {
unsigned int start = range * threadIdx;
@ -444,7 +444,7 @@ Ex02::RT::Image Ex02::RT::renderColorsWithSpheres(unsigned int outputWidth,
yIteration(y, mutex);
}
},
start, end, &mutex));
start, end, nullptr));
}
for (std::thread &thread : threads) {
thread.join();