Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2001-11-28 19:09:21


From: <williamkempf_at_[hidden]>
> --- In boost_at_y..., "Greg Colvin" <gcolvin_at_u...> wrote:
> > From: <williamkempf_at_h...>
> > > ... What is being created is an atomic counter,
> > > not an atomic integer, and as a counter there's little need for any
> > > information other than < 0, == 0, > 0. So instead of using the ++
> > > and -- operators I'd define increment() and decrement() methods and
> > > gaurantee only the above comparisons to 0. This gives you optimal
> > > portability and should cover all real needs.
> >
> > 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.

And lots of code doesn't need to be thread safe. So it's nice if
raw integers can satisfy our generic counter requirements. One
alternative might be free increment and decrement functions that
are specialized for integers and for atomic_counter.


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