Quote Originally Posted by wysota View Post
Attached you will find a real thread-safe queue I just implemented.
Thanks, I will study this carefully!....

Quote Originally Posted by wysota View Post
By the way - your queue doesn't protect you from buffer underruns (or overruns). The fact that you call "isEmpty" or "isFull" is completely meaningless as right when you return some other thread may change its state so you may be adding to a full queue or reading from an empty one. So your queue is not thread-safe in its current form.
I want to be sure to understand this properly...
you're saying that a construct like:
Qt Code:
  1. if(!asyncqueue.isEmpty()) asyncqueue.pull()
To copy to clipboard, switch view to plain text mode 
is not safe?
because between the actual test of emptiness and the actual pull, another thread could have pulled, emptying the queue possibly... and so my pull will fail...
Is that correct?
and that's why you added the semaphore on top of the mutex protection?....