220 4745 <51A7039F.20007@gmail.com> article
Path: news.gmane.org!not-for-mail
From: Anthony Williams <anthony.ajw@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: N3558 :A standardized representation of
 Asynchronous operation
Date: Thu, 30 May 2013 08:45:35 +0100
Lines: 62
Approved: news@gmane.org
Message-ID: <51A7039F.20007@gmail.com>
References: <519F9E48.7050700@wanadoo.fr> <51A0B7C3.40109@wanadoo.fr> <51A6EFE6.4030407@wanadoo.fr>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1369899942 21560 80.91.229.3 (30 May 2013 07:45:42 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 30 May 2013 07:45:42 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD65DK5LTQNBBIUHTSGQKGQEE6TSKGI@isocpp.org Thu May 30 09:45:41 2013
Return-path: <std-proposals+bncBD65DK5LTQNBBIUHTSGQKGQEE6TSKGI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ea0-f200.google.com ([209.85.215.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD65DK5LTQNBBIUHTSGQKGQEE6TSKGI@isocpp.org>)
	id 1UhxYJ-0002KD-SN
	for gclcip-std-proposals@m.gmane.org; Thu, 30 May 2013 09:45:39 +0200
Original-Received: by mail-ea0-f200.google.com with SMTP id b15sf7765255eae.3
        for <gclcip-std-proposals@m.gmane.org>; Thu, 30 May 2013 00:45:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-beenthere:message-id:date:from:user-agent:mime-version:to:subject
         :references:in-reply-to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-google-group-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type
         :content-transfer-encoding;
        bh=EJNtMnWsNnUShKU0OPbGK0/ZXlR4jJrM04/ff/MgGFs=;
        b=CgJLEtdJo2Tm/2xPkEycMug76fblVhUq/8BdpaWVCMRI4AK58z2q/+iqVzEpNQmBVA
         DDrGI57+KgQp0rm241XAQIxofsuOn3HFQS800PewOjmPIxd1WfJTTOpOJUc6ZbcTvMwG
         WRGwD3unaqOx0j0MWqNe9EKTmy8WDGMbXbJ4L/DfQ4DLytYGef2r1lgQTgFnLLqW6TMX
         OHmFgDkALKVynSphfarbT0RLZD1GUbrhyW9v9Vtr7k9ITvDCrvmzD0DDE3KCv+tUO0Sv
         V0xB29C9htbq0lONhaxDbQGvUAI6ouqLc3Y2zvNAYt3hyrFYENyROwIsUeVU4DNCpepA
 
X-Received: by 10.180.189.74 with SMTP id gg10mr2099177wic.4.1369899938399;
        Thu, 30 May 2013 00:45:38 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.36.77 with SMTP id o13ls170603wij.22.gmail; Thu, 30 May
 2013 00:45:37 -0700 (PDT)
X-Received: by 10.194.110.201 with SMTP id ic9mr3340216wjb.47.1369899937481;
        Thu, 30 May 2013 00:45:37 -0700 (PDT)
Original-Received: from mail-wi0-x22c.google.com (mail-wi0-x22c.google.com [2a00:1450:400c:c05::22c])
        by mx.google.com with ESMTPS id v4si7762699wjq.175.2013.05.30.00.45.37
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 30 May 2013 00:45:37 -0700 (PDT)
Received-SPF: pass (google.com: domain of anthony.ajw@gmail.com designates 2a00:1450:400c:c05::22c as permitted sender) client-ip=2a00:1450:400c:c05::22c;
Original-Received: by mail-wi0-f172.google.com with SMTP id m6so4247976wiv.17
        for <std-proposals@isocpp.org>; Thu, 30 May 2013 00:45:37 -0700 (PDT)
X-Received: by 10.194.47.240 with SMTP id g16mr3338221wjn.43.1369899937355;
        Thu, 30 May 2013 00:45:37 -0700 (PDT)
Original-Received: from ?IPv6:2a01:7e00:e000:2a::9001? ([2a01:7e00:e000:2a::9001])
        by mx.google.com with ESMTPSA id fz8sm36086352wib.2.2013.05.30.00.45.35
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 30 May 2013 00:45:36 -0700 (PDT)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6
In-Reply-To: <51A6EFE6.4030407@wanadoo.fr>
X-Original-Sender: anthony.ajw@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of anthony.ajw@gmail.com designates 2a00:1450:400c:c05::22c as
 permitted sender) smtp.mail=anthony.ajw@gmail.com;       dkim=pass header.i=@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?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:4745
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/4745>

On 30/05/13 07:21, Vicente J. Botet Escriba wrote:
> Le 25/05/13 15:08, Vicente J. Botet Escriba a =E9crit :
>> Le 24/05/13 19:07, Vicente J. Botet Escriba a =E9crit :
>>> Hi,
>>>
>>> What is the rationale for when_all to return
>>> future<vector<future<R>>> instead of  future<vector<R>>?
>>> What is the rationale for when_any to return
>>> future<vector<future<R>>> instead of future<pair<size_t, R>> ?
>>>
>>>
>> I have one more question about when_any. What would be the expected
>> behavior when when_any has parameters that shared the same shared
>> state, as in
>>
>>    std::shared_future<int> fi1 =3D
>> std::async(calculate_the_answer_to_life_the_universe_and_everything).sha=
re();
>>    std::shared_future<int> fi2 =3D fi1;
>>    std::when_any(fi1, fi2).wait();
>>

This will wait until the async finishes. Both futures become ready
together, so there is no problem here.

> Or even this radical one
>=20
>    std::future<int> fi1 =3D
> std::async(calculate_the_answer_to_life_the_universe_and_everything).shar=
e();
>    std::when_any(fi1, fi1).wait();

This shouldn't compile, since fi1 is not copyable, so you should have to
move it into the when_any call.

Under the current spec, the interface allows it to compile, but it may
fail due to internal implementation details, in which case the spec
needs updating.

If it did compile then I would expect it to complain about an invalid
future, since after moving the first arg the second one will be empty.

Anthony
--=20
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++11 thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

--=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/?hl=3Den.



.
