Boost logo

Boost :

From: Giora Unger (giora_at_[hidden])
Date: 1999-12-26 14:30:00


Hello Boost members,

Actually I thought about sending this to Beman Dawes only, as it's
doubtfully of interest for the public, alas - my mail server insist
that the address is not recognised. So I'll send it here.

My name is Giora Unger, and I'm a software developer
in Radcom Ltd., located in Israel.
I was struggling with Smart Pointers when a kind developer (yonat,
thanks again...) pointed me to your site and great Smart Pointers
library.
First and foremost, I'd like to express my honest appreciation
to the provided code and documentation. You (the relevant people)
really did an
impressive job.

Furthermore, I have several questions, that I'm afraid are not
of interest for the public. It'd be of great help if you could
answer and resolve my wondering.
So:
1. As far as I understand, the library is NOT thread safe.
   Am I wrong ?
   For example, let's examine line 169 in smart_ptr.h:
      if (--*pn == 0) { delete px; }
   I believe, that in case of two threads concurrently accessing
   this line (the reset() method), and an initial reference count==2,
   then a crash is possible: if both decrements occur before both
   comparisons, resulting in two deletion attempts.
   Do you, by any chance, have a list of changes necessary for
   making the library thread-safe ?

2. I'm developing in Microsoft VC++6.0, and in the boost/config.h,
    line 168, the BOOST_NO_MEMBER_TEMPLATE_FRIENDS
    is defined.
    Hence, all the private data members of my shared_ptr become
    public.
    Why is that ? Could you please elaborate about the trick with
    this parameter (there is a documentation, which I don't understand).
    How can I omit this undesired exposure, without causing any harm
    to the Smart Pointers implementation ?

And some minor questions:
3. What is scoped_ptr good for ? Isn't it included in shared_ptr ?
    In other words - assume I use shared_ptr, is there any use for
    scoped_ptr for me ?

4. The same for arrays - is shared_array used simple for arrays,
    in contrast to simple pointers to objects ? If so - what's between
    it and scoped_array ?

5. In your view, how should a comparison to NULL be performed ?
    I found out that either an explicit cast, e.g.: (ILinePtr)NULL,
    or an isNull() method are the options. So I added isNull() method.
    Did I miss anything ?

6. What is the line - typedef T element_type; (e.g., line 111)
    good for ? Commenting it out doesn't seem to influence.
    Is it safe to comment it out ?

Again, I owe you millions of thanks for the stable and convenient
implementation.
The only things that is ashamed, is the week I wasted before finding
yours, that was dedicated to struggling with one of my own ;-)

Best regards,

------------------------------
Giora Unger
Radcom Ltd.
Tel.: 972-3-6455186
Fax: 972-3-6474681
------------------------------


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