Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-11-29 10:33:40


--- In boost_at_y..., "Peter Dimov" <pdimov_at_m...> wrote:
> From: <williamkempf_at_h...>
> > --- In boost_at_y..., "Greg Colvin" <gcolvin_at_u...> wrote:
> > > The advantage of using ++ and -- is that raw integer types
support
> > them.
> >
> > And are rarely (if ever) thread safe. So you're not helping
anybody
> > by duplicating the interface of raw integer types here, IMHO.
>
> Raw integers are completely thread safe when there is only one
thread. ;-)

No, they're not. The program is safe from race conditions by the
fact that there's only one thread, but that doesn't make the integer
thread safe. I realize you know this (that's why you've got the
smiley), but I think it's important to state this. It's very
important to not do ANYTHING that gives the niave programmer the idea
that integral types are thread safe. They turn out to be enough of
the time to likely lead such a niave user into thinking they always
are. That's one reason I don't like the integer arithmetic operators
being used for increment and decrement of a thread safe counter. The
other is that the operations suggest functionality that doesn't exist
(such as post-fix versions, other integer operations or even just an
assumption on the return type).

Bill Kempf


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