Topic: Creation of atomic_futures


Author: Anthony Williams <anthony.ajw@gmail.com>
Date: Thu, 19 Nov 2009 17:17:25 CST
Raw View
Scott Meyers <usenet@aristeia.com> writes:

> 30.6.8/1 ([futures.atomic_future]/1) in N3000 says
>
>    The class template atomic_future defines a type for asynchronous return
>    objects. An atomic_future object can only be created by use of a promise
>    (30.6.5) or packaged_task (30.6.10) object.
>
>
> However, promises and packaged_tasks, like asyncs, return std::future
> objects (not std::atomic_future objects), and there is a move
> constructor from std::future to std::atomic_future, so I don't see why
>
> std::atomic_future<void> af = std::async([]{});
>
> wouldn't work.  If it does, it sure looks like the above creates a
> std::atomic_future without itself using a promise or packaged_task.
>
> Can somebody clarify what the above quote is supposed to be telling me?

It's telling you that the spec for atomic_future is incomplete, because
it wasn't part of the draft when the async paper was written/accepted.

The merge of the "futures issues" paper and the async paper was not
tidy, as you can see by the number of editorial comments across that
part of N3000. Hopefully we'll get it tidied up for CD2.

Anthony
--
Author of C++ Concurrency in Action | http://www.manning.com/williams
just::thread C++0x 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

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Scott Meyers <usenet@aristeia.com>
Date: Thu, 19 Nov 2009 13:31:11 CST
Raw View
30.6.8/1 ([futures.atomic_future]/1) in N3000 says

    The class template atomic_future defines a type for asynchronous return
    objects. An atomic_future object can only be created by use of a promise
    (30.6.5) or packaged_task (30.6.10) object.


However, promises and packaged_tasks, like asyncs, return std::future
objects (not std::atomic_future objects), and there is a move
constructor from std::future to std::atomic_future, so I don't see why

 std::atomic_future<void> af = std::async([]{});

wouldn't work.  If it does, it sure looks like the above creates a
std::atomic_future without itself using a promise or packaged_task.

Can somebody clarify what the above quote is supposed to be telling me?

Thanks,

Scott

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]