Topic: weak_ptr lock API and shared_ptr constructor taking
Author: husain jiruwala <husain.255@gmail.com>
Date: Fri, 4 Aug 2017 07:05:28 -0700 (PDT)
Raw View
------=_Part_695_1671649733.1501855528110
Content-Type: multipart/alternative;
boundary="----=_Part_696_1141887516.1501855528110"
------=_Part_696_1141887516.1501855528110
Content-Type: text/plain; charset="UTF-8"
Suggestion here is that lock API of weak_ptr and shared_ptr ctor which
takes weak_ptr as argument should atomically call reset on weak_ptr when
they fail to create a shared_ptr out of weak_ptr
This has below advantage
1) It will automatically reduce the weak count of control block when its
not possible to create a shared_ptr from weak_ptr
2) User is not required to remember to call reset on weak_ptr which might
have static storage and unless reset explicitly will never reduce the weak
count and as we know unless weak_count is zero the control block and for
make_shared version the object can not be deleted
The reset need to be done atomically in above API's so no other thread can
assign weak_ptr in-between to different control block.
Thanks
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/8e9ecba2-5836-436d-ac65-10db6fdfe274%40isocpp.org.
------=_Part_696_1141887516.1501855528110
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Suggestion here is that lock API of weak_ptr and shared_pt=
r ctor which takes weak_ptr as argument should atomically call reset on wea=
k_ptr when they fail to create a shared_ptr out of weak_ptr<div><br></div><=
div>This =C2=A0has below advantage</div><div><br></div><div>1) It will auto=
matically reduce the weak count of control block when its not possible to c=
reate a shared_ptr from weak_ptr</div><div>2) User is not required to remem=
ber to call reset on weak_ptr which might have static storage and unless re=
set explicitly will never reduce the weak count and as we know unless weak_=
count is zero the control block and for make_shared version the object can =
not be deleted</div><div><br></div><div>The reset need to be done atomicall=
y in above API's so no other thread can assign weak_ptr in-between to d=
ifferent control block.</div><div><br></div><div>Thanks</div><div><br></div=
><div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8e9ecba2-5836-436d-ac65-10db6fdfe274%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8e9ecba2-5836-436d-ac65-10db6fdfe274=
%40isocpp.org</a>.<br />
------=_Part_696_1141887516.1501855528110--
------=_Part_695_1671649733.1501855528110--
.