|
Boost : |
From: Rene Jager (renej_at_[hidden])
Date: 2001-11-20 08:18:30
Peter Dimov wrote:
> From: "Rene Jager" <renej_at_[hidden]>
> > I think that in order to keep shared_ptr useable (at least in my work
> > ;-) is to use inline assembly for
> > atomic counters as much as possible; If you have a linux box, check out
> > /usr/include/asm/atomic.h
> > that will show the basic atomic counting code; otherwise I can mail you
> > a copy
> > I use these in my own smart/ref-count pointers and the overhead is minimal
> > also, to keep the needed (assembly) code minimal, it should be checked
> > what "most common platforms"
> > provide for things like this
>
> I agree in general. I can easily make MSVC generate the relevant
>
> lock xadd [eax], edx
>
> code by simply renaming 'InterlockedIncrement' to '_InterlockedIncrement',
> which is an intrinsic. But I'm not sure what is the proper, compiler and
> platform friendly way to achieve this in other cases.
>
> Using the functions is portable to everything Win32 and is more efficient
> than a generic mutex-protected implementation.
>
> Consider the proposed implementation as a starting point that, I expect,
> will be enhanced by others.
ok, but I think it is important to consider what is at least available as "atomic"
instructions
(dec_and_test, and alike) on platforms and what is at most necessary to implement an
atomic counter for refererence counting purposes; otherwise enhancements by others
can become "impossible" on some platforms (compiler/processor arch/etc) when
operations are needed not provided on a specific platform
I'm not really familiar with the win32 platform, so I believe you right away ;-)
renej
>
>
> --
> Peter Dimov
> Multi Media Ltd.
>
> Info: http://www.boost.org Unsubscribe: <mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk