Boost logo

Boost :

Subject: Re: [boost] Boost sprint: #3407 boost::call_once not re-entrant (at least in win32)
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2009-11-23 12:46:57

On Mon, Nov 23, 2009 at 12:26 PM, Anthony Williams
<anthony.ajw_at_[hidden]> wrote:
> You don't need a new event. If the event is set it means "check the
> status". So thread enters call_once. Sees status is "running" and waits
> on the event. When the event is set it wakes and checks status. If
> status is complete, we're done. If status is running, wait for the same
> event again. If status is "not done", set it to running, reset the event
> and run the function. On completion, set status to "complete" and set
> the event. On exception, set status to "not done" and set the event.
> I'll code it up.
> Anthony
> --

It is worth giving it a try, but we went down that road in
pthreads-win32. I think the hard part is the 'reset the event' step.
There were problems with whether the event should be manual or
auto-reset, and with the 3rd thread in looping without waiting, etc.
IIRC manual means you have a hard time knowing when to reset (ie did
everyone or ANYONE wait yet - you could close too early), auto-reset
meant that each 'waker' needed to wake the next one, etc. I can't
remember what was really bad about chaining the waking of the waiters.
 Maybe it just felt a bit queasy.

But I have a lot of faith in your work, so you may very well find
something that we missed.


Boost list run by bdawes at, gregod at, cpdaniel at, john at