Subject: Re: [boost] [thread] Can Boost.Thread use Boost.Atomic without falling on a compatibility issue?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-01-13 13:45:42
Le 13/01/13 18:38, Howard Hinnant a écrit :
> On Jan 13, 2013, at 9:57 AM, Vicente J. Botet Escriba <vicente.botet_at_[hidden]> wrote:
>> This algorithm is efficient but I suspect that this algorithm is not always correct for the same reasons the Boost.Thread current algorithm is not. But on which platforms the libc++ implementation is correct? Howard, could you comment if you are reading this post.
> Yes, libc++ is currently using double-checked locking for call_once. The rationale is two-fold:
> 1. It is actually correct for those platforms I need to target today.
> 2. A correct implementation using atomic_load with memory_order_acquire wasn't available when I wrote call_once. <atomic> appeared in libc++ about 2 years later. It needed compiler support which was slow in coming.
> There are a couple of places in libc++ that need to be retrofitted to use <atomic>. In the cases where that retrofit is in a header (i.e. call_once), the retrofit will currently need to be protected by __has_feature(cxx_atomic) as clang shuts this feature off in C++03 mode.
Thanks Howard for confirming my suspicion.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk