Created
February 24, 2018 12:43
-
-
Save jesustorresdev/e28c3a07d5ed582c074c0cef4cad4f36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void FiniteBuffer::insertFrame(const QImage& frame) | |
{ | |
// Bloquear el cerrojo. Es lo mismo que hacer manualmente: | |
// mutex_.lock() | |
QMutexLocker lock(&mutex); | |
// El código del productor a partir de este punto no se | |
// ejecutará si el consumidor ha bloqueado el cerrojo | |
// primero. | |
// Insertar el frame en la cola | |
buffer_[++bufferTail_ % buffer_.size()] = frame; | |
bufferNotEmpty_.wakeAll(); // Despertar al consumidor si | |
// esperaba por más frames. | |
// El cerrojo se libera automáticamente al salir de la función | |
// y destruirse lock. Es lo mismo que hacer manualmente: | |
// mutex_.unlock() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment