I have had a similar problem in some applications I have written using venti. As Richard Bilson points out, the tempting solution is not the best one.
I think that you want to have an explicit "no more sending will happen" state, the same as a pipe where one end has been closed. Then the receiving end can get the "EOF" once it has read the remaining items and can close its side. Once both sides are closed, the queue is freed. There are various ways you could frame things (for example, you could require that the write side is always closed before the read side), but no matter what you always end up with a two-step: first the writer signals he is done (could write an empty message instead), then the reader cleans up when he sees he has gotten everything. Can hide in a library or handle explicitly. One reason that having an IsQueueEmpty complicates things is that allowing the *writer* to check whether the *reader* has gotten all the messages yet causes information to flow backward (from reader to writer). Russ
