From: William Kempf (sirwillard_at_[hidden])
Date: 2000-11-27 10:34:31
--- In boost_at_[hidden], "Michael D. Crawford" <crawford_at_g...> wrote:
> > And
> > then there's multithreading.
> I know it take extra effort, but you can do reference counting with
> multithreading. The ZRef reference counted smart pointer in ZooLib
> multithreading correctly.
> You could probably lift out ZRef and ZAtomic from ZooLib and use
> their own for multithreaded reference counting without using the
> ZooLib. http://zoolib.sourceforge.net
> It does this by using atomic addition and subtraction on the
> counts when it's getting operated on. So if you have two threads
> incrementing and decrementing the reference count it does the right
I've not looked at ZooLib (yet!), but I can tell you that if all that
was done were to use atomic increment and decrement on the ref-count
then the smart pointer is *NOT* thread safe. Copies also must copy
the pointer, and if the whole operation isn't protected I don't see
how it can be thread safe (though maybe I'm missing some subtle
ordering of operations that might achieve this).
> It wasn't easy for Andy Green to get it right, considering also the
> platform issues (and we found a small compiler bug when doing the
> operations) but it does seem to work correctly.
Then we should look here for ideas for Boost Threads as well.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk