
10 Jun
2005
10 Jun
'05
9:34 p.m.
Jody Hagins wrote:
On Fri, 10 Jun 2005 22:14:41 +0300 "Peter Dimov" <pdimov@mmltd.net> wrote:
How is a condition variable supposed to behave when used with a null mutex? Is this a legitimate use case?
I believe it is a valid use case. Consider code for something like a popping a message off a message queue. In such a case, the pop() member function would block until the message queue was not empty. In a single-thread case (i.e., using null_mutex), you would expect some kind of exception, because you can not call pop with an empty queue in a single threaded case.
Let's take a step back. Why would I use the message queue at all in a single threaded program? Its whole purpose is to enable inter-thread communication, right?