<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<!--
<!DOCTYPE page SYSTEM "file://usr/share/xml/entities/xml-iso-entities-8879.1986/ISOlat1.ent" SYSTEM "file://usr/share/xml/entities/xml-iso-entities-8879.1986/ISOpub.ent">
--><html>
  <head>
<meta http-equiv="Content-Type" content="text/html; charset=html">
    <title>N3041: Futures and Async Cleanup</title>
  </head>

  <body>
<table>
  <tr>
    <td align="left">Document Number:</td>
    <td align="left">N3041=10-0031</td>
  </tr>
  <tr>
    <td align="left">Date:</td>
    <td align="left">2010-02-15</td>
  </tr>
  <tr>
    <td align="left">Project:</td>
    <td align="left">Programming Language C++</td>
  </tr>
</table>
<p>
Detlef Vollmann &lt;<a href="mailto:dv@vollmann.ch">dv@vollmann.ch</a>&gt;<br>
</p>
<h1>N3041: Futures and Async Cleanup</h1>

<h2>Introduction</h2>
<p>
The adoption of N2996 and N2997 at the same meeting caused some
editorial trouble, as the papers both were based on the previous
working paper and were not properly aligned.
[Big apologies to the editor!]
</p>
<p>
This paper tries to clean up the whole [futures] sub-clause.
</p>

<h2>Acknowledgements</h2>

<p>Thanks to Anthony Williams, Jonathan Wakely, Daniel Kr&uuml;gler, Alisdair Meredith and Alberto Ganesh Barbati for their comments and contributions to this paper.</p>    

<h2>Proposed Changes</h2>

<h3>LWG issue 1244 (New)</h3>
<p>
In 30.6.1 [futures.overview], header <code>&lt;future&gt;</code> synopsis:<br>
Add to <code>enum class future_errc</code>:
</p>
<pre>
result_not_asynchronous
</pre>



<h3>LWG issue 1226 (Tentatively Ready)</h3>
<p>
In 30.6.1 [futures.overview], header <code>&lt;future&gt;</code> synopsis:<br>
Change:
</p>
<pre>
    constexpr error_code make_error_code(future_errc e);
    constexpr error_condition make_error_condition(future_errc e);

    extern const error_category* const future_category;
</pre>
<p>to</p>
<pre>
    error_code make_error_code(future_errc e);
    error_condition make_error_condition(future_errc e);

    const error_category&amp; future_category();
</pre>


<h3>LWG issue 1090 (Tentatively Ready)</h3>
<p>
In 30.6.1 [futures.overview], header <code>&lt;future&gt;</code> synopsis, after declaration of class template <code>packaged_task</code>:<br>
Add:
</p>
<pre>
    template &lt;class R&gt;
      void swap(packaged_task&lt;R(ArgTypes...)&gt;&amp;, packaged_task&lt;R(ArgTypes...)&gt;&amp;)
</pre>


<h3>LWG issue 1315 (Tentatively Ready)</h3>
<p>
In 30.6.1 [futures.overview], header <code>&lt;future&gt;</code> synopsis:<br>
Change:
</p>
<pre>
    template &lt;class F, class... Args&gt;
      future&lt;typename F::result_type&gt;
      async(F&amp;&amp; f, Args&amp;&amp;... args);
    template &lt;class F, class... Args&gt;
      future&lt;typename F::result_type&gt;
      async(launch policy, F&amp;&amp; f, Args&amp;&amp;... args);
</pre>
<p>to</p>
<pre>
    template &lt;class F, class... Args&gt;
      future&lt;typename result_of&lt;F(Args...)&gt;::type&gt;
      async(F&amp;&amp; f, Args&amp;&amp;... args);
    template &lt;class F, class... Args&gt;
      future&lt;typename result_of&lt;F(Args...)&gt;::type&gt;
      async(launch policy, F&amp;&amp; f, Args&amp;&amp;... args);
</pre>


<h3>LWG issue 1226 (Tentatively Ready)</h3>
<p>
In 30.6.2 [futures.errors] near paragraph 1:<br>
Change:
</p>
<pre>
extern const error_category* const future_category;
</pre>
<dl>
<dt></dt>
<dd>
<code>future_category</code> shall point to a statically initialized
object of a type derived from class <code>error_category</code>.
</dd>
to
<pre>
    const error_category&amp; future_category();
</pre>
<dt></dt>
<dd>
<em>Returns:</em>
A reference to an object derived from class <code>error_category</code>.
</dd>
</dl>

Near paragraph 3, change:
<pre>
constexpr error_code make_error_code(future_errc e);
</pre>
<dl>
<dt></dt>
<dd>
<em>Returns:</em>
<code>error_code(static_cast&lt;int&gt;(e), *future_category)</code>.
</dd>
</dl>
<p>to</p>
<pre>
error_code make_error_code(future_errc e);
</pre>
<dl>
<dt></dt>
<dd>
<em>Returns:</em>
<code>error_code(static_cast&lt;int&gt;(e), future_category())</code>.
</dd>
</dl>

Near paragraph 4, change:
<pre>
constexpr error_code make_error_condition(future_errc e);
</pre>
<dl>
<dt></dt>
<dd>
<em>Returns:</em>
<code>error_condition(static_cast&lt;int&gt;(e), *future_category)</code>.
</dd>
</dl>
<p>to</p>
<pre>
error_condition make_error_condition(future_errc e);
</pre>
<dl>
<dt></dt>
<dd>
<em>Returns:</em>
<code>error_condition(static_cast&lt;int&gt;(e), future_category())</code>.
</dd>
</dl>


<h3>LWG issue 1269 (New)</h3>
<p>
In 30.6.4 [futures.state], title:<br>
Change:
</p>
<p>Associated state</p>
<p>to</p>
<p>Associated asynchronous state</p>

<p>
In 30.6.4 [futures.state], paragraph 1:<br>
Change:
</p>
<p>
If fully initialized,
objects of type <code>future</code> ([future.future]),
<code>shared_future</code> ([future.shared_future]),
<code>atomic_future</code> ([future.atomic_future]),
<code>promise</code> ([future.promise) and
<code>packaged_task</code> ([future.task]) reference
some state that is potentially shared between several such objects.
</p>
<p>to</p>
<p>
If fully initialized,
objects that synchronize results across threads can reference
some state that is potentially shared between several such objects.
</p>
<p>[<em>Note</em>:
Futures, promises and tasks defined in this clause reference such
associated asynchronous state. --<em>end note</em>]
</p>

<p>
In 30.6.4 [futures.state], paragraph 2:<br>
Change:
</p>
<p>
This <em>associated state</em> consists of some
state information and some (possibly not yet evaluated) <em>result</em>, which
can be a (possibly void) value or an exception.
</p>
<p>to</p>
<p>
This <em>associated asynchronous state</em> consists of some
state information and some (possibly not yet evaluated) <em>result</em>, which
can be a (possibly void) value or an exception.
</p>
<p>[<em>Note</em>:
The result can be any kind of object including a function to compute
that result, as used by <code>async</code> for <code>policy=sync</code>.
--<em>end note</em>]
</p>

<p>
Before 20.6.4 [futures.state], paragraph 3:<br>
Add:
</p>
<p>
Objects that read results from associated asynchronous state are called
<em>asynchronous return object</em>.
</p>

<p>
In 30.6.4 [futures.state], paragraph 3:<br>
Change:
</p>
<p>
The <em>result</em> of such an associated state can be set by</p>
<ul>
 <li><code>promise::set_value</code></li>,
 <li><code>promise::set_exception</code></li> or
 <li><code>packaged_task::operator()</code></li>
</ul>
<p>to</p>
<p>
Objects that provide such a result, are called <em>asynchronous providers</em>.
The <em>result</em> of such an associated asynchronous state is set by
respective functions on the asynchronous provider.
</p>
<p>[<em>Note</em>:
Such as promises or tasks.
--<em>end note</em>]
</p>


<h3>LWG issue 1272 (New)</h3>
<p>
In 30.6.5 [futures.promise], synopsis:<br>
Remove:
</p>
<pre>
      void set_value(const R&amp; r);
</pre>


<h3>LWG issue 1300 (Tentatively Ready)</h3>
<p>
In 30.6.5 [futures.promise], paragraph 12:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<code>swap(*this, other)</code>
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
Exchanges the associated states of <code>*this</code> and <code>other</code>.
</dd>
</dl>

<p>
In 30.6.5 [futures.promise], after paragraph 13:<br>
Add:
</p>
<dl>
<dt></dt>
<dd>
<em>Throws:</em>
Nothing.
</dd>
</dl>


<h3>LWG issue 1272 (New)</h3>
<p>
In 30.6.5 [futures.promise], before paragraph 17:<br>
Change:
</p>
<pre>
void set_value(const R&amp; r);
</pre>
<p>to</p>
<pre>
void promise::set_value(const R&amp; r);
</pre>


<h3>LWG issue 1291 (New)</h3>
<p>
In 30.6.5 [futures.promise], paragraph 18:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Throws:</em>
<code>future_error</code> if its associated state is already ready.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Throws:</em>
<code>future_error</code> if its associated state is already ready
or, for the first version an exception thrown by the
copy constructor of <code>R</code>, or for the second version an exception
thrown by the move constructor of <code>R</code>.
</dd>
</dl>


<h3>LWG issue 1275 (New)</h3>
<p>
In 30.6.6 [futures.unique_future], paragraph 1:<br>
Change:
</p>
<p>
The class template <code>future</code> defines a type for
asynchronous return objects which do not share their associated
state. A default-constructed <code>future</code> has no
associated state. <code>future</code> objects with associated
state can only be created by use of
<code>promise</code> ([future.promise]) or <code>packaged_task</code>
([future.task]) objects, and share their associated state with
that <code>promise</code> or <code>packaged_task</code>.  Their
values or exceptions can be set by use of the <code>promise</code>
([future.promise]) or <code>packaged_task</code> ([future.task])
object that shares the same associated state.
</p>
<p>to</p>
<p>
The class template <code>future</code> defines a type for
asynchronous return objects which do not share their associated
asynchronous state with other asynchronous return objects.
A default-constructed <code>future</code> has no
associated asynchronous state. <code>future</code> objects with associated
asynchronous state can be created by functions on asynchronous providers
([futures.state] or by the move constructor
and share their associated asynchronous state with the original
asynchronous provider.
The result (values or exceptions) of <code>future</code> objects
can be set by calling a respective function on an object that
shares the same associated asynchronous state.
</p>


<h3>LWG issue 1273 (Tentatively Ready)</h3>
<p>
In 30.6.6 [futures.unique_future], paragraph 3, introduction:<br>
Change:
</p>
<p>
The effect of calling any member function other than the destructor
or the move-assignment operator on a <code>future</code>
for which <code>valid() == false</code> is undefined.
</p>
<p>to</p>
<p>
The effect of calling any member function other than the destructor
or the move-assignment operator or <code>valid()</code> on a
<code>future</code> for which <code>valid() == false</code> is undefined.
</p>



<h3>Clean-up</h3>
<p>
In 30.6.6 [futures.unique_future], paragraph 21, <code>wait()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Precondition:</em>
<code>valid() == true</code>
</dd>
<dt></dt>
<dd>
<em>Effects:</em>
if the associated state contains a deferred function, executes the deferred function. Otherwise, blocks until the associated state is ready.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Requires:</em>
<code>valid() == true</code>
</dd>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated asynchronous state is ready.
</dd>
</dl>


<h3>LWG issue 1244 (New)</h3>
<p>
In 30.6.6 [futures.unique_future], paragraph 22ff, <code>wait_for</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Precondition:</em>
<code>valid() == true</code>
</dd>
<dt></dt>
<dd>
<em>Effects:</em>
if the associated state contains a deferred function, the behavior is
unspecified. Otherwise, blocks until the associated state is ready
or until <code>rel_time</code> has elapsed.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated state is ready.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Requires:</em>
<code>valid() == true</code>
</dd>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated asynchronous state is ready
or until <code>rel_time</code> has elapsed.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated asynchronous state is ready.
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
<code>future_error</code> if an error condition occurs.
</dd>
<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
    <code>result_not_asynchronous</code> &mdash; if the associated
    asynchronous state is shared with an object that computes the result
    in the same thread in which <code>wait_for()</code> is called.
  </li>
</ul>
</dd>
</dl>

<p>
In 30.6.6 [futures.unique_future], paragraph 25ff, <code>wait_until</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Precondition:</em>
<code>valid() == true</code>
</dd>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated state is ready
or until the current time exceeds <code>abs_time</code>.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated state is ready.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Requires:</em>
<code>valid() == true</code>
</dd>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated asynchronous state is ready
or until the current time exceeds <code>abs_time</code>.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated asynchronous state is ready.
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
<code>future_error</code> if an error condition occurs.
</dd>
<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
    <code>result_not_asynchronous</code> &mdash; if the associated
    asynchronous state is shared with an object that computes the result
    in the same thread in which <code>wait_until()</code> is called.
  </li>
</ul>
</dd>
</dl>



<h3>LWG issue 1275 (New)</h3>
<p>
In 30.6.7 [future.shared_future], paragraph 1, introduction:<br>
Change:
</p>
<p>
The class template <code>shared_future</code> defines a type for
asynchronous return objects which may share their associated state. A
default-constructed <code>shared_future</code> has no associated
state. A <code>shared_future</code> object with associated state can
only be created from another <code>shared_future</code> with
associated state or a <code>future</code> object with
associated state.  Their values or exceptions can be set by use of
a <code>promise</code> ([future.promise])
or <code>packaged_task</code> ([future.task]) object that shares the
same associated state.
</p>
<p>to</p>
<p>
The class template <code>shared_future</code> defines a type for
asynchronous return objects which may share their associated
asynchronous state with other asynchronous return objects.
A default-constructed <code>shared_future</code> has no associated
asynchronous state.
A <code>shared_future</code> object with associated asynchronous state
state can be created by conversion from a <code>future</code> object
and share their associated asynchronous state with the original
asynchronous provider of the associated state.
The result (values or exceptions) of <code>shared_future</code> objects
can be set by calling a respective function on an object that
shares the same associated asynchronous state.
</p>


<h3>Clean-up</h3>
<p>
In 30.6.7 [future.shared_future], after paragraph 2, introduction:<br>
Add:
</p>
<p>
The effect of calling any member function other than
the destructor or the move-assignment operator or
<code>valid()</code> on a <code>shared_future</code> for
which <code>valid() == false</code> is undefined.
</p>


<h3>LWG issue 1304 (Tentatively Ready)</h3>
<p>
In 30.6.7 [future.shared_future], paragraph 4, <code>shared_future()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
constructs an <em>empty</em> <code>shared_future</code> that doesn't
refer to an associated asynchronous state.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
constructs an <em>empty</em> <code>shared_future</code> that doesn't
refer to an associated state.
</dd>
<dt></dt>
<dd>
<em>Postcondition:</em>
<code>valid() == false</code>
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
nothing.
</dd>
</dl>



<h3>LWG issue 1304 (Tentatively Ready), clean-up</h3>
<p>
In 30.6.7 [future.shared_future], paragraph 22, <code>wait()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
if the associated state contains a deferred function, executes the deferred function. Otherwise, blocks until the associated state is ready.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Requires:</em>
<code>valid() == true</code>
</dd>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated asynchronous state is ready.
</dd>
</dl>


<h3>LWG issue 1304 (Tentatively Ready), LWG issue 1244 (New)</h3>
<p>
In 30.6.7 [future.shared_future], paragraph 23ff, <code>wait_for()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
if the associated state contains a deferred function, the behavior is
unspecified. Otherwise, blocks until the associated state is ready
or until <code>rel_time</code> has elapsed.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated state is ready.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Requires:</em>
<code>valid() == true</code>
</dd>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated asynchronous state is ready
or until <code>rel_time</code> has elapsed.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated asynchronous state is ready.
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
<code>future_error</code> if an error condition occurs.
</dd>
<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
    <code>result_not_asynchronous</code> &mdash; if the associated
    asynchronous state is shared with an object that computes the result
    in the same thread in which <code>wait_for()</code> is called.
  </li>
</ul>
</dd>
</dl>

<p>
In 30.6.7 [future.shared_future], paragraph 25ff, <code>wait_until()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated state is ready
or until the current time exceeds <code>abs_time</code>.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated state is ready.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Requires:</em>
<code>valid() == true</code>
</dd>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated asynchronous state is ready
or until the current time exceeds <code>abs_time</code>.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated asynchronous state is ready.
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
<code>future_error</code> if an error condition occurs.
</dd>
<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
    <code>result_not_asynchronous</code> &mdash; if the associated
    asynchronous state is shared with an object that computes the result
    in the same thread in which <code>wait_until()</code> is called.
  </li>
</ul>
</dd>
</dl>



<h3>LWG issue 1275 (New)</h3>
<p>
In 30.6.8 [futures.atomic_future], paragraph 1:<br>
Change:
</p>
<p>
 The class template <code>atomic_future</code> defines a type for
 asynchronous return objects.
 These objects can only be created by use of
 <code>promise</code> ([future.promise])
 or <code>packaged_task</code> ([future.task]) objects.
 Their values or exceptions can be set
 by use of <code>promise</code> ([future.promise]) objects.
</p>
<p>to</p>
<p>
The class template <code>atomic_future</code> defines a type for
asynchronous return objects which may share their associated
asynchronous state with other asynchronous return objects.
A single <code>atomic_future</code> object may be shared between
different threads.
A default-constructed <code>atomic_future</code> has no
associated asynchronous state. <code>atomic_future</code>
objects with associated asynchronous state can be created by
conversion from a <code>future</code> object
and share their associated asynchronous state with the original
asynchronous provider of the associated state.
The result (values or exceptions) of <code>atomic_future</code> objects
can be set by calling a respective function on an object that
shares the same associated asynchronous state.
</p>


<h3>LWG issue 1274 (Tentatively Ready)</h3>
<p>
In 30.6.8 [futures.atomic_future], paragraph 6, <code>atomic_future(atomic_future&lt;R&gt;&amp;&amp; rhs)</code>:<br>
Change:
</p>
<pre>
atomic_future(atomic_future&amp;&amp; rhs);
</pre>
<p>to</p>
<pre>
atomic_future(future&lt;R&gt;&amp;&amp; rhs);
</pre>


<h3>Clean-up</h3>
<p>
In 30.6.8 [futures.atomic_future], paragraph 7ff, <code>operator=()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Precondition:</em>
<code>this-&gt;valid() == false</code>
</dd>
<dt></dt>
<dd>
<em>Effects:</em>
assigns the contents of <code>rhs</code> to <code>*this</code>.
[<em>Note</em>: So <code>*this</code> refers to the same associated
state as <code>rhs</code> (if any). --<em>end note</em>]
</dd>
<dt></dt>
<dd>
<em>Synchronization:</em>
This assignment performs an acquire operation on
<code>rhs</code> and a release operation on the left-hand side.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Requires:</em>
<code>this-&gt;valid() == false</code>
</dd>
<dt></dt>
<dd>
<em>Effects:</em>
assigns the contents of <code>rhs</code> to <code>*this</code>.
[<em>Note</em>: So <code>*this</code> refers to the same associated
asynchronous state as <code>rhs</code> (if any). --<em>end note</em>]
</dd>
<dt></dt>
<dd>
<em>Synchronization:</em>
This assignment performs an acquire operation on
<code>rhs</code> and a release operation on <code>*this</code>.
</dd>
</dl>



<h3>Clean-up</h3>
<p>
In 30.6.8 [futures.atomic_future], paragraph 17, <code>is_ready()</code>ff:<br>
Remove:
</p>
<pre>
bool is_ready() const;
</pre>

<dl>
<dt></dt>
<dd>
<em>Precondition:</em>
<code>valid() == true</code>
</dd>

<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated state is ready.
</dd>
</dl>

<pre>
bool has_exception() const;
</pre>
<dl>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated state is ready
and the associated state contains an exception.
</dd>
</dl>

<pre>
bool has_value() const;
</pre>
<dl>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated state is ready
and the associated state contains a value.
</dd>
</dl>




<h3>LWG issue 1305 (New), clean-up</h3>
<p>
In 30.6.8 [futures.atomic_future], paragraph 22, <code>wait()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated state is ready.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated asynchronous state is ready.
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
<code>future_error</code> if an error condition occurs.
</dd>
<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
    <code>no_state</code> &mdash; if <code>*this</code> has no
    associated asynchronous state.
  </li>
</ul>
</dd>
</dl>


<h3>LWG issue 1244 (New) and 1305 (New), clean-up</h3>
<p>
In 30.6.8 [futures.atomic_future], paragraph 23ff, <code>wait_for</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated state is ready
or until <code>rel_time</code> has elapsed.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated state is ready.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated asynchronous state is ready
or until <code>rel_time</code> has elapsed.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated asynchronous state is ready.
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
<code>future_error</code> if an error condition occurs.
</dd>
<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
<code>result_not_asynchronous</code> if the associated asynchronous state
    is shared with an object that computes the result in the same thread
    in which <code>wait_for()</code> is called.</li>
  <li>
<code>no_state</code> if <code>*this</code> has no associated
    asynchronous state.</li>
</ul>
</dd>
</dl>

<p>
In 30.6.8 [futures.atomic_future], paragraph 25ff, <code>wait_until()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated state is ready
or until the current time exceeds <code>abs_time</code>.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated state is ready.
</dd>
</dl>
<p>to</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated asynchronous state is ready
or until the current time exceeds <code>abs_time</code>.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if the associated asynchronous state is ready.
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
<code>future_error</code> if an error condition occurs.
</dd>
<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
<code>result_not_asynchronous</code> if the associated asynchronous state
    is shared with an object that computes the result in the same thread
    in which <code>wait_until()</code> is called.</li>
  <li>
<code>no_state</code> if <code>*this</code> has no associated
    asynchronous state.</li>
</ul>
</dd>
</dl>

<h3>Clean-up</h3>
<p>
In 30.6.9 [futures.async], just after the title:<br>
Add:
</p>
<p>
<code>async</code> provides a mechanism to launch a function potentially
in a new thread and provides the result of the function in a
<code>future</code> object, with which it shares an associated
asynchronous state.
</p>

<h3>LWG issue 1315 (Tentatively Ready)</h3>
<p>
In 30.6.9 [futures.async] synopsis:<br>
Change:
</p>
<pre>
    template &lt;class F, class... Args&gt;
      future&lt;typename F::result_type&gt;
      async(F&amp;&amp; f, Args&amp;&amp;... args);
    template &lt;class F, class... Args&gt;
      future&lt;typename F::result_type&gt;
      launch policy, async(F&amp;&amp; f, Args&amp;&amp;... args);
</pre>
<p>to</p>
<pre>
    template &lt;class F, class... Args&gt;
      future&lt;typename result_of&lt;F(Args...)&gt;::type&gt;
      async(F&amp;&amp; f, Args&amp;&amp;... args);
    template &lt;class F, class... Args&gt;
      future&lt;typename result_of&lt;F(Args...)&gt;::type&gt;
      async(launch policy, F&amp;&amp; f, Args&amp;&amp;... args);
</pre>


<p>
In 30.6.9 [futures.async], paragraph 2, after the <em>Returns:</em> clause:
Add:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
If the invocation is deferred, the associated asynchronous state
is not ready until the function has completed.
Calls to waiting functions
(<code>wait()</code> or other functions defined
in terms of <code>wait()</code>)
on asynchronous return objects that share the associated
asynchronous state created by this <code>async()</code> call synchronize.
The first of such calls shall invoke the deferred function in the thread
that called the waiting function;
all other calls waiting for the same result shall block
until the deferred function has completed.
The completion of the invocation of the deferred function happens-before
the calls to the waiting functions return.
</dd>
</dl>


<p>
In 30.6.9 [futures.async], after paragraph 3 (<em>Synchronization</em>):<br>
Add:
</p>
<p>
If the invocation is not deferred, a call to a waiting function
on asynchronous return objects that share the associated
asynchronous state created by this <code>async()</code> call
shall block until the associated thread has completed.
</p>


<h3>LWG issue 1315 (Tentatively Ready)</h3>
<p>
In 30.6.9 [futures.async], after paragraph 5:<br>
Add:
</p>
<dl>
<dt></dt>
<dd>
<em>Remarks:</em>
The first signature shall not participate in overload resolution
if <code>decay&lt;F&gt;::type</code> is <code>std::launch</code>.
</dd>
</dl>



<h3>LWG issue 1090 (Tentatively Ready)</h3>
<p>
In 30.6.10 [futures.futures_task], synopsis, after definition
of class template <code>packaged_task</code>:<br>
Add:
</p>
<pre>
    template &lt;class R, class... Argtypes&gt;
      void swap(packaged_task&lt;R(ArgTypes...)&gt;&amp;, packaged_task&lt;R(ArgTypes...)&gt;&amp;)
</pre>

<p>
In 30.6.10 [futures.futures_task], after paragraph 20:<br>
Add:
</p>
<pre>
    template &lt;class R, class... Argtypes&gt;
      void swap(packaged_task&lt;R(ArgTypes...)&gt;&amp; x, packaged_task&lt;R(ArgTypes...)&gt;&amp; y)
</pre>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<code>x.swap(y)</code>
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
nothing.
</dd>
</dl>

</body>
</html>
