Boost logo

Boost :

From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2003-02-05 19:21:19


"David B. Held" wrote:
>
> "Pavel Vasiliev" <pavel_at_[hidden]> wrote in message
> news:1111364312.20030205192141_at_mpen.bas-net.by...
> > [...]
> > In my implementation of refc_ptr operator= performs
> > incrementing/decrementing within a single guarded section (since
> > the only global instance of interl. op. mutex is used for all
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> > cases). So the copying via operator= is about twice faster in my
> > implementation.

Really? What about contention? Well, it's a nice way to play
ping-pong on a multiprocessor system... or am I just missing
and/or misunderstanding something?

> > I do not know how to achieve this with
> > Loki::SmartPtr.
> >
> > The true locking/unlocking, not InterlockedIncrement/Decrement()
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Nah, pthread_refcount_t. ;-)

> > even if availabe, is necessary to support weak references.
> > [...]
>
> Well, this is a good point, and is worthy of study at some point.

It's probably a bit more exciting to take care of all possible races
without "a true lock" protecting both counters. I'm not sure that the
true locking is *necessary* to support weak references. Do you have
an illustration, Pavel?

regards,
alexander.


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