|
Boost Users : |
From: Wu Yinghui, Freddie (yhwu_at_[hidden])
Date: 2006-03-25 08:47:30
divick kishore wrote:
>>>Yes, in that you can safely copy pointers in
>>>multiple threads at the
>>>same time, i.e. access to the reference count is
>>>thread-safe.
>>>No, in that you cannot use a single smart pointer
>>>object simultaneously
>>>from several threads.
>
> The above two statements are conflicting. You say that
> access to reference count is thread safe but while
> access to shared_ptr from multiple threads is not
> thread safe. Then what is the benefit of it being
> thread safe if you cannot use it from multiple
> threads.
No, they are not. You misunderstood the statements.
> Also being thread safe means read and write both are
> thread safe. So once you say that it is thread safe,
> then I assume that you mean both read and write are
> thread safe. In the above statements, is that what you
> mean?
What that reply meant was as following:
- You may safely manipulate the smart_ptr<> instance itself, including
modification to the reference count;
- You may not safely use the object pointed to by the smart_ptr<>
instance, if that object is not thread-safe.
> I am now even more confused about the thread safety of
> smart pointers. Could you please elaborate it more.
In short, the smart_ptr<> class's thread safety is limited to the
smart_ptr<> instances themselves, but not to the objects pointed to by
the smart_ptr<> instances.
Cheers,
Freddie
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net