|
Boost : |
Subject: Re: [boost] [xint] Boost.XInt formal review (concrete complaint)
From: Ivan Le Lann (ivan.lelann_at_[hidden])
Date: 2011-03-07 03:36:18
Le lundi 07 mars 2011 à 04:37 +0200, Peter Dimov a écrit :
> Chad Nelson wrote:
> > The only concrete complaint that people could give me about CoW was
> > that code using it couldn't be made thread-safe, which is true. So I
> > made a way to instruct the library to force all integer objects to
> > have unique storage before they're returned to user code, and made it
> > the default to prevent unpleasant client-code surprises.
>
> I don't think that this is enough to prevent surprises. If someone does
>
> thread t( f, x );
>
> where x is an integer, the thread would receive a shared copy of x. The user
> would need to explicitly call the copy constructor with a second argument of
> true to avoid that. Just use detail::atomic_count
For the platform I'm currently working on, that would mean arithmetic
full of spinlocks...
Useless sarcasm aside, isn't that an abuse of atomics?
Especially if you can stress the frontend to avoid them.
Ivan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk