Boost logo

Boost :

From: Michael D. Crawford (crawford_at_[hidden])
Date: 2000-11-24 04:05:50


> 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 handles
multithreading correctly.

You could probably lift out ZRef and ZAtomic from ZooLib and use them on
their own for multithreaded reference counting without using the rest of
ZooLib. http://zoolib.sourceforge.net

It does this by using atomic addition and subtraction on the reference
counts when it's getting operated on. So if you have two threads
incrementing and decrementing the reference count it does the right thing.

It wasn't easy for Andy Green to get it right, considering also the cross-
platform issues (and we found a small compiler bug when doing the atomic
operations) but it does seem to work correctly.

Regards,

Mike Crawford


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