Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-05-22 16:52:38


--- In boost_at_y..., Beman Dawes <bdawes_at_a...> wrote:
> The whole thing with atomic_t might be a red herring. It may well
be that
> thread_safe_int_least32_t needs a full set of integer operations.
So even
> if sizeof(int)==32, it can't just be a typedef for atomic_t.

I just realized what you're saying here. I don't think there's any
way to natively give a full set of integer operations to a type with
out using a mutex. I'm not aware of any platform that gives atomic
multiplication, for instance. You can't mix and match usage here so
even if atomic addition is supported, since atomic multiplication
isn't you'd have to use a mutex for both operations. At that point
the granularity of the lock combined with the usage would result in a
very poor type indeed, and you'd likely find a better design would be
to use a non-thread safe integer and a mutex at a higher level of
granularity. Atomic integer operations are really only useful for
counting (increment and decrement) or swapping.

Bill Kempf


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