Boost logo

Boost :

Subject: Re: [boost] Boost sprint: #3407 boost::call_once not re-entrant (at least in win32)
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2009-11-25 03:32:02


Gottlob Frege <gottlobfrege_at_[hidden]> writes:

>> I've checked in a new version on trunk
>>
>> https://svn.boost.org/svn/boost/trunk/boost/thread/win32/once.hpp
>>
>> It's not as tidy as I'd like, but I think the logic is sound.
>>
>
> Probably, except you never actually wait on the event! :-)
> (or maybe I missed it).

Oops! I thought I'd put it at the end of the loop.

> Also, once_flag is no longer a POD (because of the destructor). Not
> sure if that is important. It is also now approx 4 * sizeof(long)
> instead of just sizeof(long or pointer). :-(

Lack of POD-ness is not important because it can still be statically
initialized. The increased size is unfortunate. You can probably get
away with packing the flags and counts into the same word at the expense
of having to use a CAS loop to update them (for the counts to exceed
even 16 bits would be highly unlikely).

Anthony

-- 
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++0x thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk