I am pretty sure that we actually already said that the queue always had to be big enough that it never overruns. I seem to remember talking about that explicitly, and also this assert would seem to indicate that I baked that requirement right into the code:
| Assert(NewNextEntryToWrite != Queue->NextEntryToRead);
|
So I think the understanding here was that the write pointer is never allowed to approach the read pointer, because you actually don't even need the race condition you are describing to happen for a problem, right - the write pointer will just keep on going and romp pending reads all day long if the queue overflows!
It's not particularly difficult to do a system that is better (one that does not have overflow problems, and that allows multiple producer/consumer), but I don't know whether we want to really get into multithreading on HH. We'll see! The hard part tends not to be the queueing, but the data access part.
- Casey