Re: Atomic Reference Counting - Do you think this would be useful to Boost?
Earl Purple wrote:
Chris Thomasson wrote:
Currently, Boost doesn't provide support for "true"
atomically thread-safe atomic reference counting:
http://groups.google.com/group/comp.programming.threads/msg/7b02ce7b874e6551
I have created an experimental prototype of one of my atomic reference
counting algorithms I posted over in c.p.t:
http://groups.google.com/group/comp.programming.threads/msg/be47a566e4388e0a
Does anybody think that Boost could make use of this level of
thread-safety?
In boost I think there's an option to do so already in
reference-counted pointers. The only problem is that there is
no standard way to do atomic reference counting.
Or rather, that the "standard" way (using Boost::mutex) can be
somewhat slow on some platforms.
I actually have my own version that has optional atomic
counting and it is used only when necessary. Most of the time
it is not. Passing objects across threads using a
producer/consumer queue is one of the few occasions when they
are used. A large collection being manipulated by a single
thread (at a time) is an occasion when they are not.
shared_ptr doesn't have the semantics you want when passing
objects accross threads. What you need is auto_ptr.
Regretfully, there's no way of getting an auto_ptr from a
shared_ptr. (On the other hand, I've never had any problem with
auto_ptr's semantics in this case, using raw pointers for
weak_ptr's. Perhaps a weak_ptr for auto_ptr would be the
answer.)
--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]