|
Boost : |
From: William Kempf (sirwillard_at_[hidden])
Date: 2000-08-31 09:14:08
--- In boost_at_[hidden], "Greg Colvin" <gcolvin_at_u...> wrote:
> This one is necessary, but tough. On platforms which don't
> have the necessary instructions to do one of these operations
> atomically without a mutex they will be expensive, so I
> would lean more towards the minimal useful subset that is
> doable (often in only in assembly) on most machines without a
> mutex.
The "expensiveness" of the mutex is debatable. For some realtime
critical operations I'd agree, but in those cases you're probably not
concerned with portability any way and will resort to assembler.
Other than that, I agree with you, and we should find a minimal
interface that's likely to be easily ported to most platforms in as
efficient a manner as possible.
> For example, after an increment or decrement you may not have
> atomic access to the new value, but only to a condition code
> that tells you whether it is zero. So it might be better to
> return a bool from increment and decrement rather than force
> a slower implementation.
I was under the impression that you'd usually be able to test for 0,
<0 and >0. Hence the return value of long. It's not necessarily the
current value for the counter, but it allows you to test for more
than just 0. WinNT allows a test for the actual value, while Win9x
only allows the three tests against zero.
Bill Kempf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk