[cpp-threads] High-level vs. low-level

Alexander Terekhov alexander.terekhov at gmail.com
Thu Jul 13 21:30:37 BST 2006


On 7/13/06, Peter Dimov <pdimov at mmltd.net> wrote:
> Alexander Terekhov wrote:
> > On 7/13/06, Peter Dimov <pdimov at mmltd.net> wrote:
>
> >>     int __atomic x;
> >
> > Uh. And why not simply atomic_int (could use std::atomic<int> under
> > the cover a la <iohw.h> -> <hardware> from the TR, see Appendix C)?
>
> Mainly because I want atomics that work on pointers:
>
>     int * px;

atomic<int *> px;

(Die hard C fans are used to macros... something a la
__STD_ATOMIC_PTR(int). No?)

>
> and structs:
>
>     struct { short a; short b; } x;
>     struct { void* a; void* b; } x2; // only if DWCAS supported

atomic_pair<>

>
> and unions:
>
>     union { char a[3]; int _for_alignment; } x;

atomic<some_union>

regards,
alexander.



More information about the cpp-threads mailing list