Sunday, May 22, 2016

Digest for comp.programming.threads@googlegroups.com - 1 update in 1 topic

Bonita Montero <Bonita.Montero@gmail.com>: May 21 10:04PM +0200

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/
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.programming.threads+unsubscribe@googlegroups.com.

No comments: