Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2003-11-16 14:06:30

Larry Evans wrote:


> when updating a pointer, a thread must know the previous value
> of the pointer slot being updated
> I guess this means when <(T1,S1),R1> is changed to <(T1,S1),R2> where
> (T1,S1) is a smart pointer,S1, with pointee, R1 in thread, T1, and
> and it's updated to point to R2, then "must know the previous value"
> means it must decrement RC(R1). If so, then this highlights a
> weakness
> of the weighted RC (WRC) sheme. As mentioned, any decrement with WRC
> requires synchronization. So maybe this "on-the-fly rc" (OTFRC) is
> the
> way to go.

I am still not sure... I am thinking about a _signed_ reference counter now
which would be quite fast also and wouldn't need any locking or loop
mechanism because only 1 access to the counter would be necessary. I know
what I am thinking of is possible in assembly language but its portability
needs to be proven in C++.

What I am thinking of is to decrement the counter immediately as soon as the
smart pointer's detructor (or reset) is called. Other threads could do the
same thing but only 1 thread would be the one responsible for getting the
counter equal to 0... other ones would get some counter less than 0. Then
you will be able to determine the first thread to have destroyed the

I think it is a matter of 'how' it is programmed logically at this level;
not really how it is abstracted.


Boost list run by bdawes at, gregod at, cpdaniel at, john at