Subject: Re: [boost] [lockfree::fifo] Review
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-12-06 16:29:23
On Fri, Dec 4, 2009 at 11:01 AM, Andrew Venikov
> 3. Your tail_ and head_ should be volatile. Furthermore, the getters for
> you tagged_ptr (like get_ptr, operator->() and operator* ) should return
> pointers/references to volatile types.
> Rational: If your tail_ is not volatile, then the compiler is free to load
> head_ just once and line 4 effectively becomes a no-op.
A little late chiming in here, but I think volatile is neither necessary nor
sufficient to guarantee that the compiler does not perform such
optimizations. If it works, it's due to implementation specific extensions
of the volatile keyword, such as those provided by Microsoft's compiler
which does indeed guarantee that such optimizations are not performed on
volatile variables. However, I don't believe this is the case for all
compilers (although it might be true for many). In any case, it's
definitely not standards compliant behavior, and my understanding of
volatile (which seems to change every time someone publishes a new paper
about just how bad it is) is that it's almost completely useless for
portable, standards compliant behavior.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk