I built my own blocking queue in Qt and I was having a little problem. If I do not close the queue, then I get an error message in the console " QWaitCondition: Destroyed while threads are still waiting ". On the other hand, I get an access violation exception after closing the queue (regardless of whether it is in the constructor or another thread). An exception occurs in standby standby standby.
Here is my blocking queue:
#ifndef BLOCKING_QUEUE_H
I assume this is because the thread waiting for the message after the queue has already been destroyed, and the mutex will also be destroyed. When a thread wakes up in TryDequeue , the mutex is no longer allocated, so it throws an access violation exception. What is the best way to avoid this?
Kiril source share