I have two threads. Both are talking to GPU. The first one is responsible for rendering the other one for loading stuff. When the first one is actually rendering and not doing other things the second one has to stop. They can run in parallel but that will introduce framerate spikes. So it's ok to make one loop in loading thread but no more. I implemented this behavior with std::mutex but i don't like it since the second thread is actually toggling mutex and could slow down rendering thread. How can it be implemented in cleaner way?
//Master thread
{
std::lock_guard<std::mutex> lg(gpuMutex);
// rendering
}
//Slave thread
while(true) {
gpuMutex.lock();
gpuMutex.unlock();
// loading
}
Aucun commentaire:
Enregistrer un commentaire