Boost logo

Boost :

From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2004-09-22 05:50:23


Tomas Puverle <Tomas.Puverle_at_[hidden]> wrote:
> > Also, why not including windows.h directly, like this:
> > #define WIN32_LEAN_AND_MEAN
> > #include <windows.h>
>
> I believe WIN32_EXTRA_LEAN may be even better.
>
> > <side-note>
> > From my tests it seems your version as is now fails to link
> > for gcc (unresolved external
> > _InterlockedIncrement/_InterlockedDecrement).
> > However, if #including <windows.h> and use
> > InterlockedIncrement/Decrement - they work.
> > </side-note>
>
> That is not suprising - Interlocked* are parts of the Win32 API.
>
> In fact, it has been a complete mistery to me as to why boost doesn't
> use atomic operations for its ref counting. The mutex on the counter
> was one of the big reasons why people here decided not to use
> shared_ptr.

Atomic operations are highly platform-dependent, with different
platforms having different capabilities and many requiring use of
assembly language rather than providing an API for atomic operations.
Second, shared_ptr has two counters and updating them safely without
using a lock requires some subtlety. It's something I meant to
implement but hadn't quite got round to. Perhaps I could make it work
on g++ (and hence most Linux configurations) by using libstdc++'s
atomic primitives? I don't think they are really public though, so
this might be a bad idea.


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