Re: multithreading.
On 29 mar, 04:09, Chris Thomasson <cris...@comcast.net> wrote:
On Sat, 29 Mar 2008 01:39:41 +0000, Jon Harrop wrote:
Chris Thomasson wrote:
"Jon Harrop" <use...@jdh30.plus.com> wrote in message
news:13uqrd4qo5f890b@corp.supernews.com...
You should really look at a language with a concurrent garbage collect=
or
if you want to do multithreading. C++ really falls down here because i=
t
lacks a good foundation.
Why do you think one needs a garbage collector in order to
implement multi-threaded algorithms?
Unless your allocation lifetimes happen to be statically
well defined, you'll essentially end up reinventing a
garbage collector. That is hard enough in single threaded
applications but it is much harder in the presence of
multithreading because it is so error prone.
That does not make sense. I choose the right lifetime
management scheme for the algorithms I need to implement.
Object lifetime and garbage collection are orthogonal---garbage
collectors do NOT manage object lifetime. And of course, both
are orthogonal to threading---except that like just about
everything else, it's harder to implement the algorithms used
(garbage collector, or the alternatives) in the presence of
threads.
To this date, I have not "needed" full-blown garbage
collection.
You never "need" it. (For that matter, you never need C++, or
even C. You can do everything in assembler.)
I mainly make use of distributed reference counting and proxy
collectors to manage the memory in non-blocking algorithms.
This is not reinventing a garbage collector at all. BTW,
garbage collectors have their share of problems; here are some
of them:
http://groups.google.com/group/comp.programming.threads/browse_frm/th...
Nothing is perfect, and there are contexts where garbage
collection may not be the answer. Or garbage collection mixed
with something else. It's a nice option to have, and makes
coding a few specific things easier, but it's not a silver
bullet.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34