Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::weak_ptr usage in multithreaded environments
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2010-02-01 10:23:28


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 01 February 2010, Virgil Palanciuc wrote:
> I am assuming in my app. that weak_ptr<>.lock() only requires a "read
> lock", not a "write lock".. is this true?
> I've checked out the page at
> http://www.boost.org/doc/libs/1_41_0/libs/smart_ptr/shared_ptr.htm#ThreadSa
>fety, but there's nothing about weak_ptr there...

Creating and destroying shared_ptr (including those created through
weak_ptr::lock) doesn't require any locking at all, as far as the reference
counting goes. Unless you are trying to simultaneously access the same
weak_ptr/shared_ptr object (rather than copies pointing at the same thing)
from different threads?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAktm8fAACgkQ5vihyNWuA4V1JQCg0rLz8jT5h9ppc0MRxPA7Duwr
J5kAnAvt0js3cbBVtQ6E53ePd2XNXE5N
=bMMy
-----END PGP SIGNATURE-----


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