220 17609 <9A3E0561DCF227429F72080EA81ADBC95084453ECA@TUS1XCHEVSPIN42.SYMC.SYMANTEC.COM> article
Path: news.gmane.org!not-for-mail
From: Michael Spertus <mike_spertus@symantec.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: RE: Comments on N4470 "Variadic lock_guard"
Date: Thu, 30 Apr 2015 06:44:26 -0700
Lines: 964
Approved: news@gmane.org
Message-ID: <9A3E0561DCF227429F72080EA81ADBC95084453ECA@TUS1XCHEVSPIN42.SYMC.SYMANTEC.COM>
References: <f3536471-72fe-4077-ae82-d508cd41607a@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative;
	boundary="_000_9A3E0561DCF227429F72080EA81ADBC95084453ECATUS1XCHEVSPIN_"
X-Trace: ger.gmane.org 1430401502 12306 80.91.229.3 (30 Apr 2015 13:45:02 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 30 Apr 2015 13:45:02 +0000 (UTC)
To: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>, "std-proposals@isocpp.org"
	<std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDRKVPVDWYNBBUPDRCVAKGQEM7QKEPQ@isocpp.org Thu Apr 30 15:44:51 2015
Return-path: <std-proposals+bncBDRKVPVDWYNBBUPDRCVAKGQEM7QKEPQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wi0-f197.google.com ([209.85.212.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDRKVPVDWYNBBUPDRCVAKGQEM7QKEPQ@isocpp.org>)
	id 1Ynolm-0003EH-LA
	for gclcip-std-proposals@m.gmane.org; Thu, 30 Apr 2015 15:44:50 +0200
Original-Received: by wiun10 with SMTP id n10sf4793984wiu.1
        for <gclcip-std-proposals@m.gmane.org>; Thu, 30 Apr 2015 06:44:50 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:to:date:subject:thread-topic:thread-index
         :message-id:references:in-reply-to:accept-language:content-language
         :acceptlanguage:content-type:mime-version:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=JuNWDM7l3k7Swhbi6oPQwYPJ64WRN39cBc3efJ4pKuE=;
        b=fTWfUeykllx8dgb2wfyrvRLw+mLxWGd5+JZa5W2w0FCle64N1tjj2n6PKQG7rRHle2
         xDhUf3giplvuYw0PzXwijFRcx8ve+1JXYjtr1Gc86txIR+xhRauruLTBVM9R951nGZAu
         pMmthzGo9U70YTSYE9ImWTvx96+YFO4dQRA+hY+SWzEvhzjeqG+lmuzVjyxdEI6B+ssv
         HYyfQ+ZEG7+riqquJCwUGvKxZHqUZ06/KwmZoumjHpjQC/HjQaiGcoN0kW1pxUb2q+zf
         JN+ZPm389iVN+dSbPFBvcjcvZz19CRsgE2 
X-Gm-Message-State: ALoCoQlryZ8Lx5ukU1SRQVl2s2lV/wBTsyaDZz5wboWEknLvsI3nxgj4ifEj1XHk1ztDCUDNkxjE
X-Received: by 10.152.8.17 with SMTP id n17mr2599800laa.0.1430401490053;
        Thu, 30 Apr 2015 06:44:50 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.211.205 with SMTP id ne13ls132047wic.36.gmail; Thu, 30 Apr
 2015 06:44:48 -0700 (PDT)
X-Received: by 10.194.175.70 with SMTP id by6mr9029150wjc.42.1430401488742;
        Thu, 30 Apr 2015 06:44:48 -0700 (PDT)
Original-Received: from ecl1mtaoutpex02.symantec.com (ecl1mtaoutpex02.symantec.com. [166.98.1.210])
        by mx.google.com with ESMTPS id dx2si2934347wib.2.2015.04.30.06.44.47
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Thu, 30 Apr 2015 06:44:48 -0700 (PDT)
Received-SPF: pass (google.com: domain of mike_spertus@symantec.com designates 166.98.1.210 as permitted sender) client-ip=166.98.1.210;
X-AuditID: a66201d2-f78fe6d000005a74-7c-554231cecd05
Original-Received: from ecl1mtahubpin02.ges.symantec.com (ecl1mtahubpin02.ges.symantec.com [10.48.69.202])
	by ecl1mtaoutpex02.symantec.com (Symantec Brightmail Gateway out) with SMTP id 44.BE.23156.EC132455; Thu, 30 Apr 2015 13:44:46 +0000 (GMT)
Original-Received: from [155.64.220.137] (helo=TUS1XCHHUBPIN01.SYMC.SYMANTEC.COM)
	by ecl1mtahubpin02.ges.symantec.com with esmtp (Exim 4.76)
	(envelope-from <mike_spertus@symantec.com>)
	id 1Ynolg-0007CE-WE; Thu, 30 Apr 2015 09:44:45 -0400
Original-Received: from TUS1XCHEVSPIN42.SYMC.SYMANTEC.COM ([155.64.221.73]) by
 TUS1XCHHUBPIN01.SYMC.SYMANTEC.COM ([155.64.220.137]) with mapi; Thu, 30 Apr
 2015 06:44:43 -0700
Thread-Topic: Comments on N4470 "Variadic lock_guard"
Thread-Index: AdCDLml1n7EZQ/+dRLCzq4x31uxCLQAF1J4A
In-Reply-To: <f3536471-72fe-4077-ae82-d508cd41607a@isocpp.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
acceptlanguage: en-US
X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRmVeSWpSXmKPExsXCZeB6SvecoVOowfOvChZPV65gsfh6PcqB
	yWPnrLvsHhPfz2QJYIrisklJzcksSy3St0vgypj4VrBgxguWikMLn7M1MM65wdLFyMkhIWAi
	8fBlJxOELSZx4d56ti5GLg4hgXeMEqffPmGHcF4xSvy91s8M4axklLjQNZcNpIVNwFBi8odz
	YKNEBNIllq1YzghiswioSjzpvwBWIwy0orX3B1SNqcTC3R+ZIWwjidePNoHFeQWiJCZ2PAaL
	CwnYSlw60wzWyylgJ9F++xKYzQh03vdTa8BOZRYQl7j1ZD7U2QISS/acZ4awRSVePv7HClEv
	KnGnfT0jRH2+ROOCl8wQuwQlTs58wjKBUXQWklGzkJTNQlI2i5EDKK4psX6XPkSJosSU7ofs
	ELaGROucuezI4gsY2VcxyqQm5xjmliTml5YUpFYYGOkVV+YmAmMvWS85P3cTIzD+liUxXtrB
	eP+w7iFGAQ5GJR7ec3JOoUKsiWVAlYcYJTiYlUR4xRSAQrwpiZVVqUX58UWlOanFhxilOViU
	xHkfdoqGCgmkJ5akZqemFqQWwWSZODilGhgdsic8ZThXd/Ei82H+/j3LTLym1KpuTTG7Et42
	/7t4YqmE0rTCiANFJ5+uSApfNF3qwMrdMlpHDLWELFI7tpfnfpIpKJdalnviwCXmH5cWJcqy
	V/eZNqelu+m4//1i+O7xMrMXq5ZqWknbMXYm/e0+dMz+wMEgrWv6mo7Ou28HfJz7Xuda+3sl
	luKMREMt5qLiRAAAvJuguwIAAA==
X-Original-Sender: mike_spertus@symantec.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of mike_spertus@symantec.com designates 166.98.1.210 as permitted
 sender) smtp.mail=mike_spertus@symantec.com;       dmarc=pass (p=NONE
 dis=NONE) header.from=symantec.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:17609
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/17609>

--_000_9A3E0561DCF227429F72080EA81ADBC95084453ECATUS1XCHEVSPIN_
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Thanks for your comments.  Arthur,

1.       Absolutely, the proposal is meant to be deadlock-free, and I just =
embarrassingly put in the wording wrong. Corrected wording will be on the w=
iki. (I realized this right after submitting, but it was too late=E2=80=A6 =
I did give my students an extra credit problem to find the mistake in the p=
aper).

2.       I considered requiring that all the mutex types be the same as you=
 suggest, but some of the most important use cases require different lock t=
ypes (like Howard=E2=80=99s operator=3D example in the paper), and it just =
seems inaccurate to do otherwise.

3.       If N4471 is adopted, then you don=E2=80=99t need to worry about te=
mplate arguments.
auto guard =3D lock_guard(mtx1, mtx2);

4.       Even without N4471, since all of the common use cases we could thi=
nk of involve 0, 1, or 2 mutexes (note that 0 locks is useful as well), the=
 notational overhead isn=E2=80=99t excessive.

5.       It seems like unique_lock might also want to work with any number =
of mutexes. In that case, a make_unique_lock(=E2=80=A6) would be another wa=
y to avoid specifying the template arguments. (Since lock_guard is not mova=
ble, you can=E2=80=99t do this with lock_guards).

6.       While I sympathize with your desire to avoid raw locking primitive=
s, I think the use cases in the paper are appropriate and of course, explic=
it locks are common in practices. C++ in general has the philosophy of offe=
ring both low-level primitives and high-level abstractions. In any case, if=
 we choose to provide raw locking primitives, I think the relevant question=
 is whether or not they are better if variadic (also see #8 below).

7.       In particular, I think the built-in deadlock avoidance (Once the w=
ording embarrassment from #1 above is fixed!) will result in more reliable =
programs in practice, if only because many user-defined types follow the ru=
le of three=E2=80=99s imprecation to provide assignment operators.

8.       I=E2=80=99m having trouble seeing any reason we shouldn=E2=80=99t =
allow lock_guard to be variadic. The proposal is easy to ignore if you don=
=E2=80=99t like it, and IMO doesn=E2=80=99t add conceptual complexity. =E2=
=80=9Cstd::lock_guard can manage a set of locks of diverse types, just like=
 std::lock=E2=80=9D. I=E2=80=99ve never heard any of my students or coworke=
rs say that std::lock is more confusing because it was variadic.

What do you think,

Mike

From: Arthur O'Dwyer [mailto:arthur.j.odwyer@gmail.com]
Sent: Thursday, April 30, 2015 5:14 AM
To: std-proposals@isocpp.org
Cc: Michael Spertus
Subject: Comments on N4470 "Variadic lock_guard"

I was just reading Mike Spertus' N4470 "Variadic lock_guard":
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4470.html

My first impression was, "Wow, this is a slam-dunk obvious proposal... of c=
ourse lock_guard should be able to take multiple arguments!"
But the further I read, the uglier it seems, both in syntax and in semantic=
s.

The state of the art is:

    std::mutex mtx1, mtx2;
    ...
    std::lock_guard<std::mutex> guard1(mtx1);
    std::lock_guard<std::mutex> guard2(mtx2);  // deadlocks if somebody els=
e tries to lock mtx2 and then mtx1

or

    std::lock(mtx1, mtx2);  // cannot deadlock, per [thread.lock.algorithm]
    // if anything here throws, we forget to unlock =E2=80=94 yikes!
    std::lock_guard<std::mutex> guard1(mtx1, std::adopt_lock), guard2(mtx2,=
 std::adopt_lock);

What I'd like to see is:

    std::lock_guard<std::mutex> guard(mtx1, mtx2);
    // cannot deadlock and is exception-safe

But what N4470 actually proposes is:

    std::lock_guard<std::mutex, std::mutex> guard(mtx1, mtx2);
    // can still deadlock, because it fails to use [thread.lock.algorithm] =
for the internals

The repetition of "std::mutex, std::mutex" is ugly syntax.
The potential for deadlock is ugly semantics.

I haven't given the question too much thought, but perhaps all that's neede=
d here is a "tuple of locks" concept.
(std::apply borrowed from N3829<http://www.open-std.org/jtc1/sc22/wg21/docs=
/papers/2014/n3829.pdf>.)

template<class... Mutex>
class lock_tuple {
    std::tuple<Mutex&...> mutexes;
  public:
    explicit lock_tuple(Mutex&... mtx) : mutexes(mtx...) {}
    void lock() {
        auto locker =3D [](auto&... mtx) { std::lock(mtx...); };
        std::apply(locker, this->mutexes);
    }
    void unlock() {
        // doesn't really matter in what order we unlock them
        auto unlocker =3D [](auto&... mtx) { auto _ { ((void)mtx.unlock(), =
0)... }; };
        std::apply(unlocker, this->mutexes);
    }
};

template<class... Mutex>
lock_tuple<Mutex...> make_lock_tuple(Mutex&... mtx) {
   return lock_tuple(mtx...);
}

Then what we end up with is

    std::mutex mtx1, mtx2;
    ...
    auto both =3D make_lock_tuple(mtx1, mtx2);
    std::lock_guard<decltype(both)> guard(both);  // exception-safe AND can=
not deadlock

This strikes me as a cleaner syntax AND cleaner semantics, AND can be imple=
mented by adding one new class to the standard library instead of having to=
 replace an existing class.

One reason not to adopt either of these proposals (neither N4470<http://www=
..open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4470.html> nor lock_tuple) i=
s that they're both coming from the POV of, "I use a lot of raw locking pri=
mitives and I run into deadlock a lot, and I want to make deadlock less lik=
ely."  A very valid response would be, "Stop trying to use raw locking prim=
itives, then!"

"C++ makes it harder for you to shoot yourself in the foot, but when you do=
, it blows your whole leg off."<http://programmers.stackexchange.com/questi=
ons/92126/what-did-bjarne-stroustrup-mean-by-his-characterization-of-c-and-=
c>  Any addition to <mutex>, IMHO, has to prove that it's not simply contri=
buting to the problem of C++ programmers blowing off their legs.

my $.02,
=E2=80=93Arthur

--=20

---=20
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 e=
mail 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-proposa=
ls/.

--_000_9A3E0561DCF227429F72080EA81ADBC95084453ECATUS1XCHEVSPIN_
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40"><head><meta http-equiv=3DContent-Type content=
=3D"text/html; charset=3Dutf-8"><meta name=3DGenerator content=3D"Microsoft=
 Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
code
	{mso-style-priority:99;
	font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{mso-style-priority:34;
	margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:.5in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman",serif;}
span.styled-by-prettify
	{mso-style-name:styled-by-prettify;}
span.EmailStyle19
	{mso-style-type:personal;
	font-family:"Calibri",sans-serif;
	color:#1F497D;}
span.EmailStyle20
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
..MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
/* List Definitions */
@list l0
	{mso-list-id:1165976073;
	mso-list-type:hybrid;
	mso-list-template-ids:-1723669748 67698703 67698713 67698715 67698703 6769=
8713 67698715 67698703 67698713 67698715;}
@list l0:level1
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level2
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level3
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
@list l0:level4
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level5
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level6
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
@list l0:level7
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level8
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level9
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-US link=3Dblue vli=
nk=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal><span style=3D'f=
ont-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Thanks for =
your comments. =C2=A0Arthur,<o:p></o:p></span></p><p class=3DMsoListParagra=
ph style=3D'text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists=
]><span style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1=
F497D'><span style=3D'mso-list:Ignore'>1.<span style=3D'font:7.0pt "Times N=
ew Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![end=
if]><span style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:=
#1F497D'>Absolutely, the proposal is meant to be deadlock-free, and I just =
embarrassingly put in the wording wrong. Corrected wording will be on the w=
iki. (I realized this right after submitting, but it was too late=E2=80=A6 =
I did give my students an extra credit problem to find the mistake in the p=
aper).<o:p></o:p></span></p><p class=3DMsoListParagraph style=3D'text-inden=
t:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style=3D'font-=
size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><span style=3D'=
mso-list:Ignore'>2.<span style=3D'font:7.0pt "Times New Roman"'>&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span style=3D'fon=
t-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>I considered =
requiring that all the mutex types be the same as you suggest, but some of =
the most important use cases require different lock types (like Howard=E2=
=80=99s operator=3D example in the paper), and it just seems inaccurate to =
do otherwise.<o:p></o:p></span></p><p class=3DMsoListParagraph style=3D'tex=
t-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style=
=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><span =
style=3D'mso-list:Ignore'>3.<span style=3D'font:7.0pt "Times New Roman"'>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span sty=
le=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>If N=
4471 is adopted, then you don=E2=80=99t need to worry about template argume=
nts.<br>auto guard =3D lock_guard(mtx1, mtx2);<o:p></o:p></span></p><p clas=
s=3DMsoListParagraph style=3D'text-indent:-.25in;mso-list:l0 level1 lfo1'><=
![if !supportLists]><span style=3D'font-size:11.0pt;font-family:"Calibri",s=
ans-serif;color:#1F497D'><span style=3D'mso-list:Ignore'>4.<span style=3D'f=
ont:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></=
span></span><![endif]><span style=3D'font-size:11.0pt;font-family:"Calibri"=
,sans-serif;color:#1F497D'>Even without N4471, since all of the common use =
cases we could think of involve 0, 1, or 2 mutexes (note that 0 locks is us=
eful as well), the notational overhead isn=E2=80=99t excessive.<o:p></o:p><=
/span></p><p class=3DMsoListParagraph style=3D'text-indent:-.25in;mso-list:=
l0 level1 lfo1'><![if !supportLists]><span style=3D'font-size:11.0pt;font-f=
amily:"Calibri",sans-serif;color:#1F497D'><span style=3D'mso-list:Ignore'>5=
..<span style=3D'font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp; </span></span></span><![endif]><span style=3D'font-size:11.0pt;font=
-family:"Calibri",sans-serif;color:#1F497D'>It seems like unique_lock might=
 also want to work with any number of mutexes. In that case, a make_unique_=
lock(=E2=80=A6) would be another way to avoid specifying the template argum=
ents. (Since lock_guard is not movable, you can=E2=80=99t do this with lock=
_guards).<o:p></o:p></span></p><p class=3DMsoListParagraph style=3D'text-in=
dent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style=3D'fo=
nt-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><span style=
=3D'mso-list:Ignore'>6.<span style=3D'font:7.0pt "Times New Roman"'>&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span style=3D=
'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>While I s=
ympathize with your desire to avoid raw locking primitives, I think the use=
 cases in the paper are appropriate and of course, explicit locks are commo=
n in practices. C++ in general has the philosophy of offering both low-leve=
l primitives and high-level abstractions. In any case, if we choose to prov=
ide raw locking primitives, I think the relevant question is whether or not=
 they are better if variadic (also see #8 below).<o:p></o:p></span></p><p c=
lass=3DMsoListParagraph style=3D'text-indent:-.25in;mso-list:l0 level1 lfo1=
'><![if !supportLists]><span style=3D'font-size:11.0pt;font-family:"Calibri=
",sans-serif;color:#1F497D'><span style=3D'mso-list:Ignore'>7.<span style=
=3D'font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </sp=
an></span></span><![endif]><span style=3D'font-size:11.0pt;font-family:"Cal=
ibri",sans-serif;color:#1F497D'>In particular, I think the built-in deadloc=
k avoidance (Once the wording embarrassment from #1 above is fixed!) will r=
esult in more reliable programs in practice, if only because many user-defi=
ned types follow the rule of three=E2=80=99s imprecation to provide assignm=
ent operators.<o:p></o:p></span></p><p class=3DMsoListParagraph style=3D'te=
xt-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style=
=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><span =
style=3D'mso-list:Ignore'>8.<span style=3D'font:7.0pt "Times New Roman"'>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span sty=
le=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>I=E2=
=80=99m having trouble seeing any reason we shouldn=E2=80=99t allow lock_gu=
ard to be variadic. The proposal is easy to ignore if you don=E2=80=99t lik=
e it, and IMO doesn=E2=80=99t add conceptual complexity. =E2=80=9Cstd::lock=
_guard can manage a set of locks of diverse types, just like std::lock=E2=
=80=9D. I=E2=80=99ve never heard any of my students or coworkers say that s=
td::lock is more confusing because it was variadic.<o:p></o:p></span></p><p=
 class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",sa=
ns-serif;color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><s=
pan style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497=
D'>What do you think,<o:p></o:p></span></p><p class=3DMsoNormal><span style=
=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p>&=
nbsp;</o:p></span></p><p class=3DMsoNormal><span style=3D'font-size:11.0pt;=
font-family:"Calibri",sans-serif;color:#1F497D'>Mike<o:p></o:p></span></p><=
p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",s=
ans-serif;color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><=
b><span style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</=
span></b><span style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif'>=
 Arthur O'Dwyer [mailto:arthur.j.odwyer@gmail.com] <br><b>Sent:</b> Thursda=
y, April 30, 2015 5:14 AM<br><b>To:</b> std-proposals@isocpp.org<br><b>Cc:<=
/b> Michael Spertus<br><b>Subject:</b> Comments on N4470 &quot;Variadic loc=
k_guard&quot;<o:p></o:p></span></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></=
p><div><div><p class=3DMsoNormal>I was just reading Mike Spertus' N4470 &qu=
ot;Variadic lock_guard&quot;:<o:p></o:p></p></div><p class=3DMsoNormal><a h=
ref=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4470.html">=
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4470.html</a><o:p>=
</o:p></p><div><p class=3DMsoNormal><o:p>&nbsp;</o:p></p></div><div><p clas=
s=3DMsoNormal>My first impression was, &quot;Wow, this is a slam-dunk obvio=
us proposal... of course lock_guard should be able to take multiple argumen=
ts!&quot;<o:p></o:p></p></div><div><p class=3DMsoNormal>But the further I r=
ead, the uglier it seems, both in syntax and in semantics.<o:p></o:p></p></=
div><div><p class=3DMsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=3DMs=
oNormal>The state of the art is:<o:p></o:p></p></div><div><p class=3DMsoNor=
mal><o:p>&nbsp;</o:p></p></div><div style=3D'border:solid #BBBBBB 1.0pt;pad=
ding:0in 0in 0in 0in;word-wrap: break-word'><div><p class=3DMsoNormal style=
=3D'background:#FAFAFA'><span class=3Dstyled-by-prettify><span style=3D'fon=
t-size:10.0pt;font-family:"Courier New";color:black'>&nbsp; &nbsp; std</spa=
n></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;f=
ont-family:"Courier New";color:#666600'>::</span></span><span class=3Dstyle=
d-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";col=
or:black'>mutex mtx1</span></span><span class=3Dstyled-by-prettify><span st=
yle=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>,</span></=
span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-=
family:"Courier New";color:black'> mtx2</span></span><span class=3Dstyled-b=
y-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:=
#666600'>;</span></span><span style=3D'font-size:10.0pt;font-family:"Courie=
r New";color:black'><br><span class=3Dstyled-by-prettify>&nbsp; &nbsp; </sp=
an></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;=
font-family:"Courier New";color:#666600'>...</span></span><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New";color:black'><br><span class=3Dsty=
led-by-prettify>&nbsp; &nbsp; std</span></span><span class=3Dstyled-by-pret=
tify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#66660=
0'>::</span></span><span class=3Dstyled-by-prettify><span style=3D'font-siz=
e:10.0pt;font-family:"Courier New";color:black'>lock_guard</span></span><sp=
an class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"=
Courier New";color:#666600'>&lt;</span></span><span class=3Dstyled-by-prett=
ify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>=
std</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:=
10.0pt;font-family:"Courier New";color:#666600'>::</span></span><span class=
=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier =
New";color:black'>mutex</span></span><span class=3Dstyled-by-prettify><span=
 style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>&gt;</s=
pan></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt=
;font-family:"Courier New";color:black'> guard1</span></span><span class=3D=
styled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New=
";color:#666600'>(</span></span><span class=3Dstyled-by-prettify><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:black'>mtx1</span></s=
pan><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-f=
amily:"Courier New";color:#666600'>);</span></span><span style=3D'font-size=
:10.0pt;font-family:"Courier New";color:black'><br><span class=3Dstyled-by-=
prettify>&nbsp; &nbsp; std</span></span><span class=3Dstyled-by-prettify><s=
pan style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>::</=
span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0p=
t;font-family:"Courier New";color:black'>lock_guard</span></span><span clas=
s=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:#666600'>&lt;</span></span><span class=3Dstyled-by-prettify><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>std</sp=
an></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;=
font-family:"Courier New";color:#666600'>::</span></span><span class=3Dstyl=
ed-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";co=
lor:black'>mutex</span></span><span class=3Dstyled-by-prettify><span style=
=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>&gt;</span></=
span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-=
family:"Courier New";color:black'> guard2</span></span><span class=3Dstyled=
-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";colo=
r:#666600'>(</span></span><span class=3Dstyled-by-prettify><span style=3D'f=
ont-size:10.0pt;font-family:"Courier New";color:black'>mtx2</span></span><s=
pan class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:=
"Courier New";color:#666600'>);</span></span><span class=3Dstyled-by-pretti=
fy><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> =
&nbsp;</span></span><span class=3Dstyled-by-prettify><span style=3D'font-si=
ze:10.0pt;font-family:"Courier New";color:#880000'>// deadlocks if somebody=
 else tries to lock mtx2 and then mtx1</span></span><span style=3D'font-siz=
e:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p></div></div><div>=
<p class=3DMsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=3DMsoNormal>o=
r<o:p></o:p></p></div><div><p class=3DMsoNormal><o:p>&nbsp;</o:p></p></div>=
<div style=3D'border:solid #BBBBBB 1.0pt;padding:0in 0in 0in 0in;word-wrap:=
 break-word'><div><p class=3DMsoNormal style=3D'background:#FAFAFA'><span c=
lass=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Cour=
ier New";color:black'>&nbsp; &nbsp; std</span></span><span class=3Dstyled-b=
y-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:=
#666600'>::</span></span><span class=3Dstyled-by-prettify><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New";color:#000088'>lock</span></span><=
span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family=
:"Courier New";color:#666600'>(</span></span><span class=3Dstyled-by-pretti=
fy><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>m=
tx1</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:=
10.0pt;font-family:"Courier New";color:#666600'>,</span></span><span class=
=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier =
New";color:black'> mtx2</span></span><span class=3Dstyled-by-prettify><span=
 style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>);</spa=
n></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;f=
ont-family:"Courier New";color:black'> &nbsp;</span></span><span class=3Dst=
yled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";=
color:#880000'>// cannot deadlock, per [thread.lock.algorithm]</span></span=
><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'><br=
><span class=3Dstyled-by-prettify>&nbsp; &nbsp; </span></span><span class=
=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier =
New";color:#880000'>// if anything here throws, we forget to unlock =E2=80=
=94 yikes!</span></span><span style=3D'font-size:10.0pt;font-family:"Courie=
r New";color:black'><br><span class=3Dstyled-by-prettify>&nbsp; &nbsp; std<=
/span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0=
pt;font-family:"Courier New";color:#666600'>::</span></span><span class=3Ds=
tyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New"=
;color:black'>lock_guard</span></span><span class=3Dstyled-by-prettify><spa=
n style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>&lt;</=
span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0p=
t;font-family:"Courier New";color:black'>std</span></span><span class=3Dsty=
led-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";c=
olor:#666600'>::</span></span><span class=3Dstyled-by-prettify><span style=
=3D'font-size:10.0pt;font-family:"Courier New";color:black'>mutex</span></s=
pan><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-f=
amily:"Courier New";color:#666600'>&gt;</span></span><span class=3Dstyled-b=
y-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:=
black'> guard1</span></span><span class=3Dstyled-by-prettify><span style=3D=
'font-size:10.0pt;font-family:"Courier New";color:#666600'>(</span></span><=
span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family=
:"Courier New";color:black'>mtx1</span></span><span class=3Dstyled-by-prett=
ify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600=
'>,</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:=
10.0pt;font-family:"Courier New";color:black'> std</span></span><span class=
=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier =
New";color:#666600'>::</span></span><span class=3Dstyled-by-prettify><span =
style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>adopt_lock=
</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.=
0pt;font-family:"Courier New";color:#666600'>),</span></span><span class=3D=
styled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New=
";color:black'> guard2</span></span><span class=3Dstyled-by-prettify><span =
style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>(</span>=
</span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;fon=
t-family:"Courier New";color:black'>mtx2</span></span><span class=3Dstyled-=
by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color=
:#666600'>,</span></span><span class=3Dstyled-by-prettify><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New";color:black'> std</span></span><sp=
an class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"=
Courier New";color:#666600'>::</span></span><span class=3Dstyled-by-prettif=
y><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>ad=
opt_lock</span></span><span class=3Dstyled-by-prettify><span style=3D'font-=
size:10.0pt;font-family:"Courier New";color:#666600'>);</span></span><span =
style=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>=
</div></div><div><p class=3DMsoNormal><o:p>&nbsp;</o:p></p></div><div><p cl=
ass=3DMsoNormal>What I'd like to see is:<o:p></o:p></p></div><div><p class=
=3DMsoNormal><o:p>&nbsp;</o:p></p></div><div style=3D'border:solid #BBBBBB =
1.0pt;padding:0in 0in 0in 0in;word-wrap: break-word'><div><p class=3DMsoNor=
mal style=3D'background:#FAFAFA'><span class=3Dstyled-by-prettify><span sty=
le=3D'font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp; &nbsp;=
 std</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size=
:10.0pt;font-family:"Courier New";color:#666600'>::</span></span><span clas=
s=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:black'>lock_guard</span></span><span class=3Dstyled-by-prettify=
><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>&=
lt;</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:=
10.0pt;font-family:"Courier New";color:black'>std</span></span><span class=
=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier =
New";color:#666600'>::</span></span><span class=3Dstyled-by-prettify><span =
style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>mutex</spa=
n></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;f=
ont-family:"Courier New";color:#666600'>&gt;</span></span><span class=3Dsty=
led-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";c=
olor:black'> guard</span></span><span class=3Dstyled-by-prettify><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>(</span></sp=
an><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-fa=
mily:"Courier New";color:black'>mtx1</span></span><span class=3Dstyled-by-p=
rettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#66=
6600'>,</span></span><span class=3Dstyled-by-prettify><span style=3D'font-s=
ize:10.0pt;font-family:"Courier New";color:black'> mtx2</span></span><span =
class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Cou=
rier New";color:#666600'>);</span></span><span style=3D'font-size:10.0pt;fo=
nt-family:"Courier New";color:black'><br><span class=3Dstyled-by-prettify>&=
nbsp; &nbsp; </span></span><span class=3Dstyled-by-prettify><span style=3D'=
font-size:10.0pt;font-family:"Courier New";color:#880000'>// cannot deadloc=
k and is exception-safe</span></span><span style=3D'font-size:10.0pt;font-f=
amily:"Courier New"'><o:p></o:p></span></p></div></div><div><p class=3DMsoN=
ormal><o:p>&nbsp;</o:p></p></div><div><p class=3DMsoNormal>But what N4470 a=
ctually proposes is:<o:p></o:p></p></div><div><p class=3DMsoNormal><o:p>&nb=
sp;</o:p></p></div><div style=3D'border:solid #BBBBBB 1.0pt;padding:0in 0in=
 0in 0in;word-wrap: break-word'><div><p class=3DMsoNormal style=3D'backgrou=
nd:#FAFAFA'><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0p=
t;font-family:"Courier New";color:black'>&nbsp; &nbsp; std</span></span><sp=
an class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"=
Courier New";color:#666600'>::</span></span><span class=3Dstyled-by-prettif=
y><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>lo=
ck_guard</span></span><span class=3Dstyled-by-prettify><span style=3D'font-=
size:10.0pt;font-family:"Courier New";color:#666600'>&lt;</span></span><spa=
n class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"C=
ourier New";color:black'>std</span></span><span class=3Dstyled-by-prettify>=
<span style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>::=
</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.=
0pt;font-family:"Courier New";color:black'>mutex</span></span><span class=
=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier =
New";color:#666600'>,</span></span><span class=3Dstyled-by-prettify><span s=
tyle=3D'font-size:10.0pt;font-family:"Courier New";color:black'> std</span>=
</span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;fon=
t-family:"Courier New";color:#666600'>::</span></span><span class=3Dstyled-=
by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color=
:black'>mutex</span></span><span class=3Dstyled-by-prettify><span style=3D'=
font-size:10.0pt;font-family:"Courier New";color:#666600'>&gt;</span></span=
><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-fami=
ly:"Courier New";color:black'> guard</span></span><span class=3Dstyled-by-p=
rettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#66=
6600'>(</span></span><span class=3Dstyled-by-prettify><span style=3D'font-s=
ize:10.0pt;font-family:"Courier New";color:black'>mtx1</span></span><span c=
lass=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Cour=
ier New";color:#666600'>,</span></span><span class=3Dstyled-by-prettify><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> mtx2</=
span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0p=
t;font-family:"Courier New";color:#666600'>);</span></span><span style=3D'f=
ont-size:10.0pt;font-family:"Courier New";color:black'><br><span class=3Dst=
yled-by-prettify>&nbsp; &nbsp; </span></span><span class=3Dstyled-by-pretti=
fy><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#880000'=
>// can still deadlock, because it fails to use [thread.lock.algorithm] for=
 the internals</span></span><span style=3D'font-size:10.0pt;font-family:"Co=
urier New"'><o:p></o:p></span></p></div></div><div><p class=3DMsoNormal><o:=
p>&nbsp;</o:p></p></div><div><p class=3DMsoNormal>The repetition of &quot;<=
span style=3D'font-family:"Courier New"'>std::mutex, std::mutex</span>&quot=
; is ugly syntax.<o:p></o:p></p></div><div><p class=3DMsoNormal>The potenti=
al for deadlock is ugly semantics.<o:p></o:p></p></div><div><p class=3DMsoN=
ormal><o:p>&nbsp;</o:p></p></div><div><p class=3DMsoNormal>I haven't given =
the question <i>too</i> much thought, but perhaps all that's needed here is=
 a &quot;tuple of locks&quot; concept.<o:p></o:p></p></div><div><p class=3D=
MsoNormal>(std::apply borrowed from&nbsp;<a href=3D"http://www.open-std.org=
/jtc1/sc22/wg21/docs/papers/2014/n3829.pdf">N3829</a>.)<o:p></o:p></p></div=
><div><p class=3DMsoNormal><o:p>&nbsp;</o:p></p></div><div style=3D'border:=
solid #BBBBBB 1.0pt;padding:0in 0in 0in 0in;word-wrap: break-word'><div><p =
class=3DMsoNormal style=3D'background:#FAFAFA'><span class=3Dstyled-by-pret=
tify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#00008=
8'>template</span></span><span class=3Dstyled-by-prettify><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New";color:#666600'>&lt;</span></span><=
span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family=
:"Courier New";color:#000088'>class</span></span><span class=3Dstyled-by-pr=
ettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#666=
600'>...</span></span><span class=3Dstyled-by-prettify><span style=3D'font-=
size:10.0pt;font-family:"Courier New";color:black'> </span></span><span cla=
ss=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courie=
r New";color:#660066'>Mutex</span></span><span class=3Dstyled-by-prettify><=
span style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>&gt=
;</span></span><span style=3D'font-size:10.0pt;font-family:"Courier New";co=
lor:black'><br></span><span class=3Dstyled-by-prettify><span style=3D'font-=
size:10.0pt;font-family:"Courier New";color:#000088'>class</span></span><sp=
an class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"=
Courier New";color:black'> lock_tuple </span></span><span class=3Dstyled-by=
-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#=
666600'>{</span></span><span style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:black'><br><span class=3Dstyled-by-prettify>&nbsp; &nbsp; std</=
span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0p=
t;font-family:"Courier New";color:#666600'>::</span></span><span class=3Dst=
yled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";=
color:black'>tuple</span></span><span class=3Dstyled-by-prettify><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>&lt;</span><=
/span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font=
-family:"Courier New";color:#660066'>Mutex</span></span><span class=3Dstyle=
d-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";col=
or:#666600'>&amp;...&gt;</span></span><span class=3Dstyled-by-prettify><spa=
n style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> mutexes=
</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.=
0pt;font-family:"Courier New";color:#666600'>;</span></span><span style=3D'=
font-size:10.0pt;font-family:"Courier New";color:black'><br><span class=3Ds=
tyled-by-prettify>&nbsp; </span></span><span class=3Dstyled-by-prettify><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New";color:#000088'>publi=
c</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10=
..0pt;font-family:"Courier New";color:#666600'>:</span></span><span style=3D=
'font-size:10.0pt;font-family:"Courier New";color:black'><br><span class=3D=
styled-by-prettify>&nbsp; &nbsp; </span></span><span class=3Dstyled-by-pret=
tify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#00008=
8'>explicit</span></span><span class=3Dstyled-by-prettify><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New";color:black'> lock_tuple</span></s=
pan><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-f=
amily:"Courier New";color:#666600'>(</span></span><span class=3Dstyled-by-p=
rettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#66=
0066'>Mutex</span></span><span class=3Dstyled-by-prettify><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New";color:#666600'>&amp;...</span></sp=
an><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-fa=
mily:"Courier New";color:black'> mtx</span></span><span class=3Dstyled-by-p=
rettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#66=
6600'>)</span></span><span class=3Dstyled-by-prettify><span style=3D'font-s=
ize:10.0pt;font-family:"Courier New";color:black'> </span></span><span clas=
s=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:#666600'>:</span></span><span class=3Dstyled-by-prettify><span =
style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> mutexes</=
span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0p=
t;font-family:"Courier New";color:#666600'>(</span></span><span class=3Dsty=
led-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";c=
olor:black'>mtx</span></span><span class=3Dstyled-by-prettify><span style=
=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>...)</span></=
span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-=
family:"Courier New";color:black'> </span></span><span class=3Dstyled-by-pr=
ettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#666=
600'>{}</span></span><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew";color:black'><br><span class=3Dstyled-by-prettify>&nbsp; &nbsp; </span>=
</span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;fon=
t-family:"Courier New";color:#000088'>void</span></span><span class=3Dstyle=
d-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";col=
or:black'> </span></span><span class=3Dstyled-by-prettify><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New";color:#000088'>lock</span></span><=
span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family=
:"Courier New";color:#666600'>()</span></span><span class=3Dstyled-by-prett=
ify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>=
 </span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10=
..0pt;font-family:"Courier New";color:#666600'>{</span></span><span style=3D=
'font-size:10.0pt;font-family:"Courier New";color:black'><br><span class=3D=
styled-by-prettify>&nbsp; &nbsp; &nbsp; &nbsp; </span></span><span class=3D=
styled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New=
";color:#000088'>auto</span></span><span class=3Dstyled-by-prettify><span s=
tyle=3D'font-size:10.0pt;font-family:"Courier New";color:black'> locker </s=
pan></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt=
;font-family:"Courier New";color:#666600'>=3D</span></span><span class=3Dst=
yled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";=
color:black'> </span></span><span class=3Dstyled-by-prettify><span style=3D=
'font-size:10.0pt;font-family:"Courier New";color:#666600'>[](</span></span=
><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-fami=
ly:"Courier New";color:#000088'>auto</span></span><span class=3Dstyled-by-p=
rettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#66=
6600'>&amp;...</span></span><span class=3Dstyled-by-prettify><span style=3D=
'font-size:10.0pt;font-family:"Courier New";color:black'> mtx</span></span>=
<span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-famil=
y:"Courier New";color:#666600'>)</span></span><span class=3Dstyled-by-prett=
ify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>=
 </span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10=
..0pt;font-family:"Courier New";color:#666600'>{</span></span><span class=3D=
styled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New=
";color:black'> std</span></span><span class=3Dstyled-by-prettify><span sty=
le=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>::</span></=
span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-=
family:"Courier New";color:#000088'>lock</span></span><span class=3Dstyled-=
by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color=
:#666600'>(</span></span><span class=3Dstyled-by-prettify><span style=3D'fo=
nt-size:10.0pt;font-family:"Courier New";color:black'>mtx</span></span><spa=
n class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"C=
ourier New";color:#666600'>...);</span></span><span class=3Dstyled-by-prett=
ify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>=
 </span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10=
..0pt;font-family:"Courier New";color:#666600'>};</span></span><span style=
=3D'font-size:10.0pt;font-family:"Courier New";color:black'><br><span class=
=3Dstyled-by-prettify>&nbsp; &nbsp; &nbsp; &nbsp; std</span></span><span cl=
ass=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Couri=
er New";color:#666600'>::</span></span><span class=3Dstyled-by-prettify><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New";color:black'>apply</=
span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0p=
t;font-family:"Courier New";color:#666600'>(</span></span><span class=3Dsty=
led-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";c=
olor:black'>locker</span></span><span class=3Dstyled-by-prettify><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>,</span></sp=
an><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-fa=
mily:"Courier New";color:black'> </span></span><span class=3Dstyled-by-pret=
tify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#00008=
8'>this</span></span><span class=3Dstyled-by-prettify><span style=3D'font-s=
ize:10.0pt;font-family:"Courier New";color:#666600'>-&gt;</span></span><spa=
n class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"C=
ourier New";color:black'>mutexes</span></span><span class=3Dstyled-by-prett=
ify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600=
'>);</span></span><span style=3D'font-size:10.0pt;font-family:"Courier New"=
;color:black'><br><span class=3Dstyled-by-prettify>&nbsp; &nbsp; </span></s=
pan><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-f=
amily:"Courier New";color:#666600'>}</span></span><span style=3D'font-size:=
10.0pt;font-family:"Courier New";color:black'><br><span class=3Dstyled-by-p=
rettify>&nbsp; &nbsp; </span></span><span class=3Dstyled-by-prettify><span =
style=3D'font-size:10.0pt;font-family:"Courier New";color:#000088'>void</sp=
an></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;=
font-family:"Courier New";color:black'> unlock</span></span><span class=3Ds=
tyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New"=
;color:#666600'>()</span></span><span class=3Dstyled-by-prettify><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:black'> </span></span=
><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-fami=
ly:"Courier New";color:#666600'>{</span></span><span style=3D'font-size:10.=
0pt;font-family:"Courier New";color:black'><br><span class=3Dstyled-by-pret=
tify>&nbsp; &nbsp; &nbsp; &nbsp; </span></span><span class=3Dstyled-by-pret=
tify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#88000=
0'>// doesn't really matter in what order we unlock them</span></span><span=
 style=3D'font-size:10.0pt;font-family:"Courier New";color:black'><br><span=
 class=3Dstyled-by-prettify>&nbsp; &nbsp; &nbsp; &nbsp; </span></span><span=
 class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Co=
urier New";color:#000088'>auto</span></span><span class=3Dstyled-by-prettif=
y><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> u=
nlocker </span></span><span class=3Dstyled-by-prettify><span style=3D'font-=
size:10.0pt;font-family:"Courier New";color:#666600'>=3D</span></span><span=
 class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Co=
urier New";color:black'> </span></span><span class=3Dstyled-by-prettify><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>[](</=
span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0p=
t;font-family:"Courier New";color:#000088'>auto</span></span><span class=3D=
styled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New=
";color:#666600'>&amp;...</span></span><span class=3Dstyled-by-prettify><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> mtx</s=
pan></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt=
;font-family:"Courier New";color:#666600'>)</span></span><span class=3Dstyl=
ed-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";co=
lor:black'> </span></span><span class=3Dstyled-by-prettify><span style=3D'f=
ont-size:10.0pt;font-family:"Courier New";color:#666600'>{</span></span><sp=
an class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"=
Courier New";color:black'> </span></span><span class=3Dstyled-by-prettify><=
span style=3D'font-size:10.0pt;font-family:"Courier New";color:#000088'>aut=
o</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10=
..0pt;font-family:"Courier New";color:black'> _ </span></span><span class=3D=
styled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New=
";color:#666600'>{</span></span><span class=3Dstyled-by-prettify><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:black'> </span></span=
><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-fami=
ly:"Courier New";color:#666600'>((</span></span><span class=3Dstyled-by-pre=
ttify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#0000=
88'>void</span></span><span class=3Dstyled-by-prettify><span style=3D'font-=
size:10.0pt;font-family:"Courier New";color:#666600'>)</span></span><span c=
lass=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Cour=
ier New";color:black'>mtx</span></span><span class=3Dstyled-by-prettify><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>.</sp=
an></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;=
font-family:"Courier New";color:black'>unlock</span></span><span class=3Dst=
yled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";=
color:#666600'>(),</span></span><span class=3Dstyled-by-prettify><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:black'> </span></span=
><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-fami=
ly:"Courier New";color:#006666'>0</span></span><span class=3Dstyled-by-pret=
tify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#66660=
0'>)...</span></span><span class=3Dstyled-by-prettify><span style=3D'font-s=
ize:10.0pt;font-family:"Courier New";color:black'> </span></span><span clas=
s=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:#666600'>};</span></span><span class=3Dstyled-by-prettify><span=
 style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> </span><=
/span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font=
-family:"Courier New";color:#666600'>};</span></span><span style=3D'font-si=
ze:10.0pt;font-family:"Courier New";color:black'><br><span class=3Dstyled-b=
y-prettify>&nbsp; &nbsp; &nbsp; &nbsp; std</span></span><span class=3Dstyle=
d-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";col=
or:#666600'>::</span></span><span class=3Dstyled-by-prettify><span style=3D=
'font-size:10.0pt;font-family:"Courier New";color:black'>apply</span></span=
><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-fami=
ly:"Courier New";color:#666600'>(</span></span><span class=3Dstyled-by-pret=
tify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'=
>unlocker</span></span><span class=3Dstyled-by-prettify><span style=3D'font=
-size:10.0pt;font-family:"Courier New";color:#666600'>,</span></span><span =
class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Cou=
rier New";color:black'> </span></span><span class=3Dstyled-by-prettify><spa=
n style=3D'font-size:10.0pt;font-family:"Courier New";color:#000088'>this</=
span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0p=
t;font-family:"Courier New";color:#666600'>-&gt;</span></span><span class=
=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier =
New";color:black'>mutexes</span></span><span class=3Dstyled-by-prettify><sp=
an style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>);</s=
pan></span><span style=3D'font-size:10.0pt;font-family:"Courier New";color:=
black'><br><span class=3Dstyled-by-prettify>&nbsp; &nbsp; </span></span><sp=
an class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"=
Courier New";color:#666600'>}</span></span><span style=3D'font-size:10.0pt;=
font-family:"Courier New";color:black'><br></span><span class=3Dstyled-by-p=
rettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#66=
6600'>};</span></span><span style=3D'font-size:10.0pt;font-family:"Courier =
New";color:black'><br><br></span><span class=3Dstyled-by-prettify><span sty=
le=3D'font-size:10.0pt;font-family:"Courier New";color:#000088'>template</s=
pan></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt=
;font-family:"Courier New";color:#666600'>&lt;</span></span><span class=3Ds=
tyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New"=
;color:#000088'>class</span></span><span class=3Dstyled-by-prettify><span s=
tyle=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>...</span=
></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;fo=
nt-family:"Courier New";color:black'> </span></span><span class=3Dstyled-by=
-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#=
660066'>Mutex</span></span><span class=3Dstyled-by-prettify><span style=3D'=
font-size:10.0pt;font-family:"Courier New";color:#666600'>&gt;</span></span=
><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'><br=
><span class=3Dstyled-by-prettify>lock_tuple</span></span><span class=3Dsty=
led-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";c=
olor:#666600'>&lt;</span></span><span class=3Dstyled-by-prettify><span styl=
e=3D'font-size:10.0pt;font-family:"Courier New";color:#660066'>Mutex</span>=
</span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;fon=
t-family:"Courier New";color:#666600'>...&gt;</span></span><span class=3Dst=
yled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";=
color:black'> make_lock_tuple</span></span><span class=3Dstyled-by-prettify=
><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>(=
</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.=
0pt;font-family:"Courier New";color:#660066'>Mutex</span></span><span class=
=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier =
New";color:#666600'>&amp;...</span></span><span class=3Dstyled-by-prettify>=
<span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> mtx=
</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.=
0pt;font-family:"Courier New";color:#666600'>)</span></span><span class=3Ds=
tyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New"=
;color:black'> </span></span><span class=3Dstyled-by-prettify><span style=
=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>{</span></spa=
n><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'><b=
r><span class=3Dstyled-by-prettify>&nbsp; &nbsp;</span></span><span class=
=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier =
New";color:#000088'>return</span></span><span class=3Dstyled-by-prettify><s=
pan style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> lock_=
tuple</span></span><span class=3Dstyled-by-prettify><span style=3D'font-siz=
e:10.0pt;font-family:"Courier New";color:#666600'>(</span></span><span clas=
s=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:black'>mtx</span></span><span class=3Dstyled-by-prettify><span =
style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>...);</s=
pan></span><span style=3D'font-size:10.0pt;font-family:"Courier New";color:=
black'><br></span><span class=3Dstyled-by-prettify><span style=3D'font-size=
:10.0pt;font-family:"Courier New";color:#666600'>}</span></span><span style=
=3D'font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p></div=
></div><div><p class=3DMsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=
=3DMsoNormal>Then what we end up with is<o:p></o:p></p></div><div><p class=
=3DMsoNormal><o:p>&nbsp;</o:p></p></div><div style=3D'border:solid #BBBBBB =
1.0pt;padding:0in 0in 0in 0in;word-wrap: break-word'><div><p class=3DMsoNor=
mal style=3D'background:#FAFAFA'><span class=3Dstyled-by-prettify><span sty=
le=3D'font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp; &nbsp;=
 std</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size=
:10.0pt;font-family:"Courier New";color:#666600'>::</span></span><span clas=
s=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:black'>mutex mtx1</span></span><span class=3Dstyled-by-prettify=
><span style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>,=
</span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.=
0pt;font-family:"Courier New";color:black'> mtx2</span></span><span class=
=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier =
New";color:#666600'>;</span></span><span style=3D'font-size:10.0pt;font-fam=
ily:"Courier New";color:black'><br><span class=3Dstyled-by-prettify>&nbsp; =
&nbsp; </span></span><span class=3Dstyled-by-prettify><span style=3D'font-s=
ize:10.0pt;font-family:"Courier New";color:#666600'>...</span></span><span =
style=3D'font-size:10.0pt;font-family:"Courier New";color:black'><br><span =
class=3Dstyled-by-prettify>&nbsp; &nbsp; </span></span><span class=3Dstyled=
-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";colo=
r:#000088'>auto</span></span><span class=3Dstyled-by-prettify><span style=
=3D'font-size:10.0pt;font-family:"Courier New";color:black'> both </span></=
span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-=
family:"Courier New";color:#666600'>=3D</span></span><span class=3Dstyled-b=
y-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";color:=
black'> make_lock_tuple</span></span><span class=3Dstyled-by-prettify><span=
 style=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>(</span=
></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;fo=
nt-family:"Courier New";color:black'>mtx1</span></span><span class=3Dstyled=
-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";colo=
r:#666600'>,</span></span><span class=3Dstyled-by-prettify><span style=3D'f=
ont-size:10.0pt;font-family:"Courier New";color:black'> mtx2</span></span><=
span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family=
:"Courier New";color:#666600'>);</span></span><span style=3D'font-size:10.0=
pt;font-family:"Courier New";color:black'><br><span class=3Dstyled-by-prett=
ify>&nbsp; &nbsp; std</span></span><span class=3Dstyled-by-prettify><span s=
tyle=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>::</span>=
</span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;fon=
t-family:"Courier New";color:black'>lock_guard</span></span><span class=3Ds=
tyled-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New"=
;color:#666600'>&lt;</span></span><span class=3Dstyled-by-prettify><span st=
yle=3D'font-size:10.0pt;font-family:"Courier New";color:#000088'>decltype</=
span></span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0p=
t;font-family:"Courier New";color:#666600'>(</span></span><span class=3Dsty=
led-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";c=
olor:black'>both</span></span><span class=3Dstyled-by-prettify><span style=
=3D'font-size:10.0pt;font-family:"Courier New";color:#666600'>)&gt;</span><=
/span><span class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font=
-family:"Courier New";color:black'> guard</span></span><span class=3Dstyled=
-by-prettify><span style=3D'font-size:10.0pt;font-family:"Courier New";colo=
r:#666600'>(</span></span><span class=3Dstyled-by-prettify><span style=3D'f=
ont-size:10.0pt;font-family:"Courier New";color:black'>both</span></span><s=
pan class=3Dstyled-by-prettify><span style=3D'font-size:10.0pt;font-family:=
"Courier New";color:#666600'>);</span></span><span class=3Dstyled-by-pretti=
fy><span style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> =
&nbsp;</span></span><span class=3Dstyled-by-prettify><span style=3D'font-si=
ze:10.0pt;font-family:"Courier New";color:#880000'>// exception-safe AND ca=
nnot deadlock</span></span><span style=3D'font-size:10.0pt;font-family:"Cou=
rier New"'><o:p></o:p></span></p></div></div><div><p class=3DMsoNormal><spa=
n style=3D'font-family:"Courier New";color:black'><br></span>This strikes m=
e as a cleaner syntax AND cleaner semantics, AND can be implemented by addi=
ng one new class to the standard library instead of having to replace an ex=
isting class.<o:p></o:p></p></div><div><p class=3DMsoNormal><o:p>&nbsp;</o:=
p></p></div><div><p class=3DMsoNormal>One reason not to adopt either of the=
se proposals (neither <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/doc=
s/papers/2015/n4470.html">N4470</a> nor <span style=3D'font-family:"Courier=
 New"'>lock_tuple</span>) is that they're both coming from the POV of, &quo=
t;I use a lot of raw locking primitives and I run into deadlock a lot, and =
I want to make deadlock less likely.&quot; &nbsp;A very valid response woul=
d be, &quot;Stop trying to use raw locking primitives, then!&quot;<o:p></o:=
p></p></div><div><p class=3DMsoNormal><o:p>&nbsp;</o:p></p></div><div><p cl=
ass=3DMsoNormal><a href=3D"http://programmers.stackexchange.com/questions/9=
2126/what-did-bjarne-stroustrup-mean-by-his-characterization-of-c-and-c">&q=
uot;C++ makes it harder for you to shoot yourself in the foot, but when you=
 do, it blows your whole leg off.&quot;</a> &nbsp;Any addition to <span sty=
le=3D'font-family:"Courier New"'>&lt;mutex&gt;</span>, IMHO, has to prove t=
hat it's not simply contributing to the problem of C++ programmers blowing =
off their legs.<o:p></o:p></p></div><div><p class=3DMsoNormal><o:p>&nbsp;</=
o:p></p></div><div><p class=3DMsoNormal>my $.02,<o:p></o:p></p></div><div><=
p class=3DMsoNormal>=E2=80=93Arthur<o:p></o:p></p></div></div></div></body>=
</html>

<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 />

--_000_9A3E0561DCF227429F72080EA81ADBC95084453ECATUS1XCHEVSPIN_--

.
