Topic: [Concurrency TS] Can shared_future::then be
Author: Tony V E <tvaneerd@gmail.com>
Date: Sun, 25 Jan 2015 00:03:06 -0500
Raw View
--089e0160bda4f78d47050d72ef74
Content-Type: text/plain; charset=UTF-8
On Sat, Jan 24, 2015 at 4:30 AM, Vicente J. Botet Escriba <
vicente.botet@wanadoo.fr> wrote:
> Hi,
>
> As shared_future is copyable, I'm wondering if shared_future::then could
> be called several times as the continuation don't consume the future value.
>
> shared_future<int> f;
> auto x = f.then(fx);
> auto y = f.then(fy);
>
> IMO, the wording is not precise enough respect to this point.
> I think the intent was to allow only one call at a time.
>
> shared_future<int> f;
> auto x = f.then(fx);
> auto y = f.then(fy); // should throw an exception or undefined behavior if
> fx has not been called already
>
> What others think?
>
If I saw the above code, I would expect fx and fy to either be called one
after the other (fx first), or concurrently.
So I definitely think it needs to be specified to either work somehow or
throw.
I don't think UB is a good idea, it can be hard to know whether some other
code has already applied a then().
Also, some checking function doesn't work:
if ( ! f.is_there_a_then_already())
f.then(fy);
because with threads, that if-check is out of date by the time it returns
an answer.
So it either works (ie calls fy) and the order of fx and fy is specified
(of course we could specify that concurrent vs serial is implementation
specific (and serial is a valid instance of concurrent)), or it throws (or
returns an error somehow).
For some code, that could mean throwing based on which thread gets there
first. Not sure I like that idea either.
>
> Vicente
>
Tony
--
---
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/.
--089e0160bda4f78d47050d72ef74
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Sat, Jan 24, 2015 at 4:30 AM, Vicente J. Botet Escriba <span dir=3D"=
ltr"><<a href=3D"mailto:vicente.botet@wanadoo.fr" target=3D"_blank">vice=
nte.botet@wanadoo.fr</a>></span> wrote:<br><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
">
=20
=20
=20
<div bgcolor=3D"#FFFFFF" text=3D"#000000">
<font size=3D"+1">Hi,<br>
<br>
As shared_future is copyable, I'm wondering if shared_future::the=
n
could be called several times as the continuation don't consume
the future value.<br>
<br>
shared_future<int> f;<br>
auto x =3D f.then(fx);<br>
</font><font size=3D"+1"><font size=3D"+1">auto y =3D f.then(fy);<br>
</font><br>
IMO, the wording is not precise enough respect to this point. <br>
I think the intent was to allow only one call at a time.<br>
<br>
</font><font size=3D"+1">shared_future<int> f;<br>
auto x =3D f.then(fx);<br>
</font><font size=3D"+1"><font size=3D"+1">auto y =3D f.then(fy); //
should throw an exception or undefined behavior if fx has not
been called already<br>
</font></font><br>
What others think?<span class=3D"HOEnZb"><font color=3D"#888888"><br></=
font></span></div></blockquote><div><br></div><div>If I saw the above code,=
I would expect fx and fy to either be called one after the other (fx first=
), or concurrently.<br></div><div>So I definitely think it needs to be spec=
ified to either work somehow or throw.<br></div><div>I don't think UB i=
s a good idea, it can be hard to know whether some other code has already a=
pplied a then().<br></div><div>Also, some checking function doesn't wor=
k:<br><br></div><div>=C2=A0=C2=A0=C2=A0 if ( ! f.is_there_a_then_already())=
<br></div><div>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 f.then(fy);<br><b=
r></div><div>because with threads, that if-check is out of date by the time=
it returns an answer.<br><br></div><div>So it either works (ie calls fy) a=
nd the order of fx and fy is specified (of course we could specify that con=
current vs serial is implementation specific (and serial is a valid instanc=
e of concurrent)), or it throws (or returns an error somehow).<br><br></div=
><div>For some code, that could mean throwing based on which thread gets th=
ere first.=C2=A0 Not sure I like that idea either.<br></div><div>=C2=A0<br>=
</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div bgcolor=3D"#FFFFFF" text=3D"#0000=
00"><span class=3D"HOEnZb"><font color=3D"#888888">
<br>
Vicente<br></font></span></div></blockquote><div><br><br></div><div>Ton=
y <br></div><br><br></div></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" 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 />
--089e0160bda4f78d47050d72ef74--
.
Author: Artur Laksberg <Artur.Laksberg@microsoft.com>
Date: Mon, 26 Jan 2015 01:08:53 +0000
Raw View
--_000_CY1PR0301MB12109F816F12485322DC210788350CY1PR0301MB1210_
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Vicente,
As per Concurrency TS, shared_future::then does not invalidate the object, =
so multiple continuations can be attached. This is an important property th=
at allows one to spin off multiple tasks in parallel. (The implementation k=
eeps a collection of continuations that start after the completion of the s=
hared_future)
This is different from (unique) futures. The future::then invalidates the o=
bject (as per N4107, 2.2/8). Then, according to 30.6.6/3, the effect of cal=
ling then on it is undefined.
Artur
From: Vicente J. Botet Escriba [mailto:vicente.botet@wanadoo.fr]
Sent: Saturday, January 24, 2015 1:30
To: std-proposals@isocpp.org; Artur Laksberg
Subject: [Concurrency TS] Can shared_future::then be called several times
Hi,
As shared_future is copyable, I'm wondering if shared_future::then could be=
called several times as the continuation don't consume the future value.
shared_future<int> f;
auto x =3D f.then(fx);
auto y =3D f.then(fy);
IMO, the wording is not precise enough respect to this point.
I think the intent was to allow only one call at a time.
shared_future<int> f;
auto x =3D f.then(fx);
auto y =3D f.then(fy); // should throw an exception or undefined behavior i=
f fx has not been called already
What others think?
Vicente
--=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_CY1PR0301MB12109F816F12485322DC210788350CY1PR0301MB1210_
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=3D"Content-Type" content=3D"text/html; charset=3Dutf-8">
<meta name=3D"Generator" 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;}
@font-face
{font-family:"Segoe UI";
panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#222A35;
font-weight:normal;
font-style:normal;}
..MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></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 bgcolor=3D"white" lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri",sans-serif;color:#222A35">Vicente,<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri",sans-serif;color:#222A35"><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri",sans-serif;color:#222A35">As per Concurrency TS,
<i>shared_future::then</i> does not invalidate the object, so multiple cont=
inuations can be attached. This is an important property that allows one to=
spin off multiple tasks in parallel. (The implementation keeps a collectio=
n of continuations that start after
the completion of the <i>shared_future</i>)<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri",sans-serif;color:#222A35"><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri",sans-serif;color:#222A35">This is different from (unique) futur=
es. The
<i>future::then</i> invalidates the object (as per N4107, 2.2/8). Then, acc=
ording to 30.6.6/3, the effect of calling
<i>then</i> on it is undefined.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri",sans-serif;color:#222A35"><o:p> </o:p></span></p>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri",sans-serif;color:#222A35">Artur<o:p></o:p></span></p>
</div>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri",sans-serif;color:#222A35"><o:p> </o:p></span></p>
<div>
<div style=3D"border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in =
0in 0in">
<p class=3D"MsoNormal"><b><span style=3D"font-size:11.0pt;font-family:"=
;Calibri",sans-serif;color:windowtext">From:</span></b><span style=3D"=
font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtex=
t"> Vicente J. Botet Escriba [mailto:vicente.botet@wanadoo.fr]
<br>
<b>Sent:</b> Saturday, January 24, 2015 1:30<br>
<b>To:</b> std-proposals@isocpp.org; Artur Laksberg<br>
<b>Subject:</b> [Concurrency TS] Can shared_future::then be called several =
times<o:p></o:p></span></p>
</div>
</div>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:13.5pt">Hi,<br>
<br>
As shared_future is copyable, I'm wondering if shared_future::then could be=
called several times as the continuation don't consume the future value.<b=
r>
<br>
shared_future<int> f;<br>
auto x =3D f.then(fx);<br>
auto y =3D f.then(fy);<br>
<br>
IMO, the wording is not precise enough respect to this point. <br>
I think the intent was to allow only one call at a time.<br>
<br>
shared_future<int> f;<br>
auto x =3D f.then(fx);<br>
auto y =3D f.then(fy); // should throw an exception or undefined behavior i=
f fx has not been called already<br>
</span><br>
What others think?<br>
<br>
Vicente<o:p></o:p></p>
</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" 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_CY1PR0301MB12109F816F12485322DC210788350CY1PR0301MB1210_--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Mon, 26 Jan 2015 08:23:42 +0100
Raw View
This is a multi-part message in MIME format.
--------------020907000208060506010309
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 26/01/15 02:08, Artur Laksberg a =C3=A9crit :
>
> Vicente,
>
> As per Concurrency TS, /shared_future::then/ does not invalidate the=20
> object, so multiple continuations can be attached. This is an=20
> important property that allows one to spin off multiple tasks in=20
> parallel. (The implementation keeps a collection of continuations that=20
> start after the completion of the /shared_future/)
>
> This is different from (unique) futures. The /future::then/=20
> invalidates the object (as per N4107, 2.2/8). Then, according to=20
> 30.6.6/3, the effect of calling /then/ on it is undefined.
>
>
I missed the point, it is clear now.
Vicente
--=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/.
--------------020907000208060506010309
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">Le 26/01/15 02:08, Artur Laksberg a
=C3=A9crit=C2=A0:<br>
</div>
<blockquote
cite=3D"mid:CY1PR0301MB12109F816F12485322DC210788350@CY1PR0301MB1210.namprd=
03.prod.outlook.com"
type=3D"cite">
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf=
-8">
<meta name=3D"Generator" 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;}
@font-face
{font-family:"Segoe UI";
panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#222A35;
font-weight:normal;
font-style:normal;}
..MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></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]-->
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri",sans-serif;color:=
#222A35">Vicente,<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri",sans-serif;color:=
#222A35"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri",sans-serif;color:=
#222A35">As
per Concurrency TS,
<i>shared_future::then</i> does not invalidate the object,
so multiple continuations can be attached. This is an
important property that allows one to spin off multiple
tasks in parallel. (The implementation keeps a collection of
continuations that start after the completion of the <i>shared_=
future</i>)<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri",sans-serif;color:=
#222A35"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri",sans-serif;color:=
#222A35">This
is different from (unique) futures. The
<i>future::then</i> invalidates the object (as per N4107,
2.2/8). Then, according to 30.6.6/3, the effect of calling
<i>then</i> on it is undefined.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri",sans-serif;color:=
#222A35"><o:p>=C2=A0</o:p></span></p>
<br>
</div>
</blockquote>
I missed the point, it is clear now.<br>
<br>
Vicente<br>
</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" 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 />
--------------020907000208060506010309--
.