There was a conceptual flaw in my code which led to a race-condition.
And there was another bug, which, if I fixed it with the former con-
cept, would heave led to a similar race-condition.
So I had to rewrite my condvar completely.
Here it is:
http://pastebin.com/fdjHx9ec
Now the code is including a unit-test.
Theres something important with my code:
First Release() and ReleaseAll() can be called only while holding
the condvar; that's different from the posix-condvars, which can
be signalled without holding the mutex. When NDEBUG isn't defined,
my code always assert()s whether the thread calling Release() or
ReleaseAll() is holding the condvar.
Second, making Wait() having a timeout would make the simple approach
I took impossible. I'm pretty sure my approach is more efficient than
any implementation of posix-conforming condvars. If you would like
to have a timeout, you would have a timed Release() from another
thread.
--
http://facebook.com/bonita.montero/