220 15352 <fbea1ed7-48da-47bf-b019-3a9cbd55e158@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Ramkumar Revanur <write2ramkumar@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: get count of std::weak_ptr objects tracking a
 shared resource
Date: Sun, 28 Dec 2014 08:01:41 -0800 (PST)
Lines: 131
Approved: news@gmane.org
Message-ID: <fbea1ed7-48da-47bf-b019-3a9cbd55e158@isocpp.org>
References: <a9c1d3d5-761d-44df-b722-ae649440ea77@isocpp.org> <4797942.dAdOve4yz0@tjmaciei-mobl4> <f4ce9b23-01ae-40f8-b750-0685859bb59f@isocpp.org>
 <2024731.u6vkxqVIEh@tjmaciei-mobl4>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_48_2133082613.1419782501073"
X-Trace: ger.gmane.org 1419782509 29785 80.91.229.3 (28 Dec 2014 16:01:49 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 28 Dec 2014 16:01:49 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCD4HFPP7UBRBZWSQCSQKGQEIORTBAQ@isocpp.org Sun Dec 28 17:01:45 2014
Return-path: <std-proposals+bncBCD4HFPP7UBRBZWSQCSQKGQEIORTBAQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f197.google.com ([209.85.160.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCD4HFPP7UBRBZWSQCSQKGQEIORTBAQ@isocpp.org>)
	id 1Y5GHn-0003QA-MQ
	for gclcip-std-proposals@m.gmane.org; Sun, 28 Dec 2014 17:01:43 +0100
Original-Received: by mail-yk0-f197.google.com with SMTP id 142sf37849249ykq.8
        for <gclcip-std-proposals@m.gmane.org>; Sun, 28 Dec 2014 08:01:42 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=KA2uBDZMmnS+xB3MSj+Wfq/wmMIz9NTASQHcc+Rud44=;
        b=E+2q0f02PyoQQvTHmaLBeXEJmZOUnG/5jpNq3O6slPH5H3j4EgTqrSvkuStNeTgv1W
         b97M66T+i4aFapSL+vb5eWKeSjpwprvmVrTFuZ+Cx7ejTZow7dquIrRxLwPpK8hGBQP6
         ZdVolZpm7OmBqfKgFwmPytOq3Bh/w6CpX7d/GmsinTx0v/oSDnNtejAgxMU0egeUH7h5
         p2MvoIOghrV+MKUC9Tuir2bmqPBMiALS6TqKOzpRIq6zUSSWVkUz6R8yTD8/wB8co6oP
         nnRjZeky1hTvnD33nafqxIbWQcbAIH/O2gR9Skd4jelPKhJHAakF4Rtn/Qtq5pdzMOsr
         52+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:content-type:x-original-sender:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=KA2uBDZMmnS+xB3MSj+Wfq/wmMIz9NTASQHcc+Rud44=;
        b=DFV6eyx5h/yC9GQZETmljFtcmyU52zId75aun1UNLNGTq8tp/+ADnHtDaBCNO0rPt9
         hrjZaVjg8nuuv6S2TkmukNzb2Ji905nJil4EBDMjc+TLwFmBfa2sM1E76v6r8wQCC2ST
         Te128fkp8GZsGZI0mIdLQBcbgIzSQYhe0Hyn8lRDD1CCfYTQQ2sABlW4COIIRHNkbt09
         vVuFU+8x6KOJEEsK1IQ987ZpGs2FsTP7xPX6ZTDP5e0F9rdsPzycEiHA1+ef/PXTAs5B
         BKPWYK5qTEOVpxqVdp2921qOiCUuWeUSUutzsMQYOBvLQztm+SMwjMI0MwKUeml4rEC1
         XQcQ==
X-Gm-Message-State: ALoCoQlw5jcdKk43s5z9nvnUgIlAZLuL6GrAHlRxKvBdDCgrG8nXOHpVMg4R2jGhIvIOo3JGrNw5
X-Received: by 10.236.202.207 with SMTP id d55mr42780685yho.4.1419782502651;
        Sun, 28 Dec 2014 08:01:42 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.129.165 with SMTP id l37ls5241502ioi.100.gmail; Sun, 28
 Dec 2014 08:01:41 -0800 (PST)
X-Received: by 10.50.110.101 with SMTP id hz5mr624799igb.6.1419782501957;
        Sun, 28 Dec 2014 08:01:41 -0800 (PST)
In-Reply-To: <2024731.u6vkxqVIEh@tjmaciei-mobl4>
X-Original-Sender: write2ramkumar@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:15352
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/15352>

------=_Part_48_2133082613.1419782501073
Content-Type: multipart/alternative; 
	boundary="----=_Part_49_627473673.1419782501073"

------=_Part_49_627473673.1419782501073
Content-Type: text/plain; charset=UTF-8

Look at the implementation of boost.

http://www.boost.org/doc/libs/1_57_0/boost/interprocess/smart_ptr/detail/shared_count.hpp

Boost has an implementation for weak_count!

template<class T, class VoidAllocator, class Deleter>
class weak_count { ... };




On Sunday, December 28, 2014 7:33:06 PM UTC+5:30, Thiago Macieira wrote:
>
> On Saturday 27 December 2014 20:46:29 Ramkumar Revanur wrote: 
> > > "Not to mention that any value you get is stale the 
> > > moment you got it, since weak_ptr is thread-safe and the atomic 
> counter 
> > > may 
> > > have changed values already." 
> > 
> > The use_count on a shared_ptr will be as stale as the "weak_count" if 
> that 
> > was available. Does not mean it is not useful! 
>
> Please see my other email about this. 
>
> This function is not only returning stale info, it may return *incorrect* 
> information. The only condition under which it would return correct info 
> is 
> when you already know the information that it would return (that this is 
> the 
> only reference). 
>
> -- 
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org 
>    Software Architect - Intel Open Source Technology Center 
>       PGP/GPG: 0x6EF45358; fingerprint: 
>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358 
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_49_627473673.1419782501073
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Look at the implementation of boost.<div><br></div><div>ht=
tp://www.boost.org/doc/libs/1_57_0/boost/interprocess/smart_ptr/detail/shar=
ed_count.hpp</div><div><br></div><div>Boost has an implementation for weak_=
count!</div><div><br></div><div><pre style=3D"margin: 1.5em; padding: 0.5em=
; font-size: 11px; border: 1px solid rgb(204, 204, 204); overflow: auto; cl=
ear: left; color: rgb(0, 0, 0);">template&lt;class T, class VoidAllocator, =
class Deleter&gt;
class weak_count { ... };</pre><div><br></div><div><br></div><br>On Sunday,=
 December 28, 2014 7:33:06 PM UTC+5:30, Thiago Macieira wrote:<blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
 #ccc solid;padding-left: 1ex;">On Saturday 27 December 2014 20:46:29 Ramku=
mar Revanur wrote:
<br>&gt; &gt; "Not to mention that any value you get is stale the
<br>&gt; &gt; moment you got it, since weak_ptr is thread-safe and the atom=
ic counter
<br>&gt; &gt; may
<br>&gt; &gt; have changed values already."
<br>&gt;=20
<br>&gt; The use_count on a shared_ptr will be as stale as the "weak_count"=
 if that
<br>&gt; was available. Does not mean it is not useful!
<br>
<br>Please see my other email about this.
<br>
<br>This function is not only returning stale info, it may return *incorrec=
t*=20
<br>information. The only condition under which it would return correct inf=
o is=20
<br>when you already know the information that it would return (that this i=
s the=20
<br>only reference).
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%=
3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNEswDUBNCNanbu7euhq=
Ln_62FW8ag';return true;" onclick=3D"this.href=3D'http://www.google.com/url=
?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNEswDUBNC=
Nanbu7euhqLn_62FW8ag';return true;">macieira.info</a> - thiago (AT) <a href=
=3D"http://kde.org" target=3D"_blank" onmousedown=3D"this.href=3D'http://ww=
w.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQj=
CNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'http:=
//www.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75=
AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a>
<br>&nbsp; &nbsp;Software Architect - Intel Open Source Technology Center
<br>&nbsp; &nbsp; &nbsp; PGP/GPG: 0x6EF45358; fingerprint:
<br>&nbsp; &nbsp; &nbsp; E067 918B B660 DBD1 105C &nbsp;966C 33F5 F005 6EF4=
 5358
<br>
<br></blockquote></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_49_627473673.1419782501073--
------=_Part_48_2133082613.1419782501073--

.
