<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
  <head>
<meta http-equiv="Content-Type" content="text/html; charset=html">
    <title>N3058: Futures and Async Cleanup (Rev.)</title>
<style type="text/css">
ins {background-color:#A0FFA0}
del {background-color:#FFA0A0}
</style>
  </head>

  <body>
<table>
  <tr>
    <td align="left">Document Number:</td>
    <td align="left">N3058=10-0048</td>
  </tr>
  <tr>
    <td align="left">Date:</td>
    <td align="left">2010-03-11</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>N3058: Futures and Async Cleanup (Rev.)</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, Jos&eacute; Daniel Garc&iacute;a S&aacute;nchez, Hans Boehm, Pete Becker, Alberto Ganesh Barbati and the Concurrency subgroup for their comments and contributions to this paper.</p>    

<h2>Resolved Issues</h2>
<p>
Apart from a number of editor's notes, this proposal resolves the
following LWG issues:
</p>
<p>
1090 (Ready, added swap to header, otherwise copied verbatim)<br>
1226 (Ready, copied verbatim)<br>
1244 (New, agreed on enum return)<br>
1266 (New, taken proposed semantics, but different wording, ok'ed by Anthony)<br>
1269 (New, different wording, same semantics, ok'ed by Anthony)<br>
1272 (New, proposed resolution copied verbatim)<br>
1273 (Ready, proposed resolution copied verbatim)<br>
1274 (Ready, proposed resolution copied verbatim)<br>
1275 (New, suggestions from issue taken and created wording<br>
1291 (New, proposed resolution copied with editorial change<br>
1300 (Ready, proposed resolution copied verbatim)<br>
1304 (Ready, proposed resolution copied verbatim)<br>
1305 (New, proposed resolution partly taken)<br>
1315 (Ready, proposed resolution copied verbatim)<br>
</p>


<h2>Proposed Changes</h2>
The changes applied here assume that the proposed change of LWG issue 929
(<code>decay_copy()</code>) was already applied to the working paper.

<h3>LWG issue 1244 (New)</h3>
<p>Add a new enumeration <code>future_status</code> to 30.6.1 [futures.overview]
  following the definition of the <code>launch</code> enumeration:</p>

<pre>
  enum class future_status {
      ready,
      timeout,
      deferred
  };
</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>
    <del>constexpr </del>error_code make_error_code(future_errc e);
    <del>constexpr </del>error_condition make_error_condition(future_errc e);

    <del>extern </del>const error_category<del>*</del><ins>&amp;</ins> const future_category<ins>()</ins>;
</pre>


<h3>LWG issue 1090 (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 <del>F::result_type</del><ins>result_of&lt;F(Args...)&gt;::type</ins>&gt;
      async(F&amp;&amp; f, Args&amp;&amp;... args);
    template &lt;class F, class... Args&gt;
      future&lt;typename <del>F::result_type</del><ins>result_of&lt;F(Args...)&gt;::type</ins>&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>
<del>extern</del> const error_category<ins>&amp;</ins><del>* const</del> future_category<ins>()</ins>;

</pre>
<dl>
<dt></dt>
<dd>
<del><code>future_category</code> shall point to a statically initialized
 object of a type derived from class <code>error_category</code>.</del>
</dd>
<dt></dt>
<dd>
<ins><em>Returns:</em>
A reference to an object of a type derived from class
<code>error_category</code>.</ins>
</dd>
</dl>

Near paragraph 3, change:
<pre>
<del>constexpr</del> 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),
<del>*</del>future_category<ins>()</ins>)</code>.
</dd>
</dl>

Near paragraph 4, change:
<pre>
<del>constexpr</del> error_<del>code</del><ins>condition</ins> make_error_condition(future_errc e);
</pre>

<dl>
<dt></dt>
<dd>
<em>Returns:</em>
<code>error_condition(static_cast&lt;int&gt;(e),
<del>*</del>future_category<ins>()</ins>)</code>.
</dd>
</dl>


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

<p>
In 30.6.4 [futures.state], paragraph 1ff:<br>
Change:
</p>
<p>
<del>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.</del>
</p>
<p><ins>Many of the classes introduced in this sub-clause use some state
to communicate results.
</ins>
This <em>associated <ins>asynchronous</ins> state</em> consists of some
state information and some (possibly not yet evaluated) <em>result</em>, which
can be a (possibly <code>void</code>) value or an exception.
<ins>[<em>Note</em>:
Futures, promises and tasks defined in this clause reference such
associated asynchronous state. --<em>end note</em>]</ins></p>
<p><ins>[<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 = launch::sync</code>.
--<em>end note</em>]
</ins></p>
<p><ins>
Objects that read results from associated asynchronous state are called
<em>asynchronous return objects</em>.
</ins></p>
<p>
<ins>Objects that provide such a result, are called
<em>asynchronous providers</em>.</ins>
The <em>result</em> of such an associated <ins>asynchronous</ins> state
<del>can be</del> <ins>is</ins> set by
<del><ul>
 <li><del><code>promise::set_value</code>,</del></li>
 <li><del><code>promise::set_exception</code> or</del></li>
 <li><del><code>packaged_task::operator()</code></del></li>
</ul></del>
<ins>respective functions on the asynchronous provider.
[<em>Note</em>: Such as promises or tasks. --<em>end note</em>]
The means of setting the result of an associated asynchronous state is
specified in the description of those classes and functions that create
such a state object.
</ins></p>
<p>
When the last reference to an associated <ins>asynchronous</ins> state
is given up, any resources held by this associated
<ins>asynchronous</ins> state are released.
</p>
<p>
An associated <ins>asynchronous</ins> state is <em>ready</em>
only if it holds a value or an exception ready for retrieval.
<ins>Waiting for an associated asynchronous state to
become ready may invoke code to compute the result on the waiting
thread, if so specified in the description of the class or function that
creates such a state object.</ins>
</p>
<p>
<del>The</del><ins>Calls to</ins> functions that successfully set the stored
result of an
associated <ins>asynchronous</ins> state synchronize with ([intro.multithread])
calls to <del>member</del> functions <del>of other objects referring to</del>
<ins>successfully detecting the <em>ready</em> status resulting from that
setting</ins> <del>the same
associated <ins>asynchronous</ins> state and such calls are serialized</del>.
The storage of the result (whether normal or exceptional) into the
associated <ins>asynchronous</ins> state happens-before ([intro.multithread])
that state is set to <em>ready</em>.
</p>
<p>
Accesses to the same associated <ins>asynchronous</ins> state
<del>through member functions of
<code>future</code>, <code>shared_future</code>,
<code>atomic_future</code>, <code>promise</code>
or <code>packaged_task</code> objects</del> conflict ([intro.multithread]).
</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>Clean-up</h3>
<p>
In 30.6.5 [futures.promise], paragraph 3, <code>promise()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
constructs a <code>promise</code> object and an associated
<ins>asynchronous</ins> state.
The second constructor uses the allocator <code>a</code>
to allocate memory for the associated <ins>asynchronous</ins> state.
</dd>
</dl>

<p>
In 30.6.5 [futures.promise], paragraph 4f, <code>promise(promise &amp;&amp;)</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
Constructs a new <code>promise</code> object and
transfers ownership of the associated <ins>asynchronous</ins> state of
<code>rhs</code> (if any) to the newly-constructed object.
</dd>

<dt></dt>
<dd>
<em>Postcondition:</em>
<code>rhs</code> has no associated <ins>asynchronous</ins> state.
</dd>
</dl>

<p>
In 30.6.5 [futures.promise], paragraph 7, <code>~promise()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
If the <ins>asynchronous</ins> state associated with <code>*this</code> is
not ready, stores an exception of type <code>future_error</code>
with an error <del>code</del><ins>condition</ins>
of <code>broken_promise</code><del> as-if
by <code>&gt;this-&gt;set_exception(copy_exception(future_error(future_errc::broken_promise)))</code></del>.
Any threads blocked in a function waiting for the <ins>asynchronous</ins>
state associated with <code>*this</code> to become ready are unblocked.
</dd>
<dt></dt>
<dd>
Destroys <code>*this</code> and releases its reference to its
associated <ins>asynchronous</ins> state if any. If this is the last reference
to that associated <ins>asynchronous</ins> state, destroys that state.
</dd>
</dl>

<p>
In 30.6.5 [futures.promise], paragraph 9, <code>operator=()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Postcondition:</em>
<code>rhs</code> has no associated <ins>asynchronous</ins>state.
<code>*this</code> has the associated <ins>asynchronous</ins> state of
<code>rhs</code> prior to the assignment.
</dd>
</dl>

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

<dt></dt>
<dd>
<em>Postcondition:</em>
<code>*this</code> has the same associated <ins>asynchronous</ins> state
(if any) as <code>other</code> prior to the call
to <code>swap</code>. <code>other</code> has the same associated
<ins>asynchronous</ins> state (if any) as <code>*this</code> prior to the call
to <code>swap</code>.
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
Nothing.
</dd>
</dl>


<h3>Clean-up</h3>
<p>
In 30.6.5 [futures.promise], paragraph 14ff, <code>get_future()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Returns:</em>
a <code>future&lt;R&gt;</code> object with the same associated
<ins>asynchronous</ins> state as <code>*this</code>.
</dd>

<dt></dt>
<dd>
<em>Throws:</em>
<code>future_error</code> if <code>*this</code> has no associated
<ins>asynchronous</ins> state, or if <code>get_future()</code> has already
been called on a <code>promise</code> with the associated
<ins>asynchronous</ins> state of <code>*this</code>.
</dd>
<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
<code>future_already_retrieved</code> if <code>get_future</code>
    has already been called on
    a <code>promise</code> with the associated <ins>asynchronous</ins> state
    of <code>*this</code>.</li>
  <li>
<code>no_state</code> if <code>*this</code> has no associated
    <ins>asynchronous</ins> state.</li>
</ul>
</dd>
</dl>




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


<h3>LWG issue 1291 (New)</h3>
<p>
In 30.6.5 [futures.promise], paragraph 17ff, set_value():<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
Atomically stores <code>r</code> in the associated <ins>asynchronous</ins>
state and sets that state to ready.
Any threads blocked in a call of a blocking function of any future that
refers to the same associated <ins>asynchronous</ins>
state as <code>*this</code> are unblocked.
</dd>

<dt></dt>
<dd>
<em>Throws:</em>
<ul>
  <li>
<code>future_error</code> if its associated <ins>asynchronous</ins> state
      is already ready<ins> or,</ins>
</li>
  <li><ins>for the first version an exception thrown by the
      copy constructor of <code>R</code>, or</ins></li>
  <li>
<ins>for the second version an exception thrown by the move
      constructor of <code>R</code></ins>.</li>
</ul>
</dd>

<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
<code>promise_already_satisfied</code> if its associated
      <ins>asynchronous</ins> state is already ready.</li>
  <li>
<code>no_state</code> if <code>*this</code> has no associated
  <ins>asynchronous</ins>state.</li>
</ul>
</dd>

<dt></dt>
<dd>
<em>Synchronization:</em>
Calls to <code>set_value</code> and <code>set_exception</code> on
a single <code>promise</code> object are serialized.
</dd>
<dt></dt>
<dd>[<em>Note</em>:
And they synchronize and serialize with other functions through the
referred associated <ins>asynchronous</ins> state. --<em>end note</em>]
</dd>
</dl>


<h3>Clean-up</h3>
<p>
In 30.6.5 [futures.promise], paragraph 21ff, set_exception():<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
Atomically stores <code>p</code> in the associated <ins>asynchronous</ins>
state and sets that state to ready. Any threads blocked in a call of a
blocking function of any future that refers to the same associated
<ins>asynchronous</ins> state as <code>*this</code> are unblocked.
</dd>

<dt></dt>
<dd>
<em>Throws:</em>
<code>future_error</code> if its associated <ins>asynchronous</ins> state
is already ready.
</dd>

<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
<code>promise_already_satisfied</code> if its associated
    <ins>asynchronous</ins> state is already ready.</li>
  <li>
<code>no_state</code> if <code>*this</code> has no associated
  <ins>asynchronous</ins>state.</li>
</ul>
</dd>

<dt></dt>
<dd>
<em>Synchronization:</em>
Calls to <code>set_value</code> and <code>set_exception</code> on
a single <code>promise</code> object are serialized.
</dd>
<dt></dt>
<dd>[<em>Note</em>:
And they synchronize and serialize with other functions through the
referred associated <ins>asynchronous</ins> state. --<em>end note</em>]
</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
<ins>asynchronous</ins> state <ins>with other asynchronous return objects</ins>.
A default-constructed <code>future</code> has no
associated <ins>asynchronous</ins> state. <code>future</code> objects with
associated <ins>asynchronous</ins> state can <del>only</del> be created by
<del>use of <code>promise</code> ([future.promise]) or
<code>packaged_task</code> ([future.task]) objects,</del>
<ins>functions on asynchronous providers ([futures.state] or by the move
constructor</ins>  and share their associated <ins>asynchronous</ins> state
with
<del>that <code>promise</code> or <code>packaged_task</code>.  Their</del>
<ins>the original asynchronous provider.
The result (</ins>values or exceptions<ins>) of <code>future</code> objects</ins>
can be set by
<del>use of the <code>promise</code>
([future.promise]) or <code>packaged_task</code> ([future.task])</del>
<ins>calling a respective function on an</ins>
object that shares the same associated <ins>asynchronous</ins> 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 <ins>or <code>valid()</code></ins> on a
<code>future</code> for which <code>valid() == false</code> is undefined.
</p>


<h3>LWG issue 1244 (New)</h3>
<p>In 30.6.6 [futures.unique_future], after paragraph 3, synopsis:<br>
Change:
</p>
<pre>
  template &lt;class Rep, class Period&gt;
  <del>bool</del><ins>future_status</ins> wait_for(const chrono::duration&lt;Rep, Period&gt;&amp; rel_time) const;
  template &lt;class Clock, class Duration&gt;
  <del>bool</del><ins>future_status</ins> wait_until(const chrono::time_point&lt;Clock, Duration&gt;&amp; abs_time) const;
</pre>


<h3>Clean-up</h3>
In 30.6.6 [futures.unique_future], paragraph 5, <code>future()</code>:<br>
<p>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
constructs an <em>empty</em> <code>future</code> that <del>not</del> does
<ins>not</ins> refer to an associated <ins>asynchronous</ins> state.
</dd>
</dl>

<p>
In 30.6.6 [futures.unique_future], paragraph 7, <code>future(future&amp;&amp;)</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
move constructs a <code>future</code> object that refers to the
associated <ins>asynchronous</ins> state that was originally
referred to by <code>rhs</code> (if any).
</dd>
</dl>

<p>
In 30.6.6 [futures.unique_future], paragraph 10, <code>~future()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<ul>
  <li>gives up the reference to its associated <ins>asynchronous</ins> state.</li>
  <li>destroys <code>*this</code>.</li>
</ul>
</dd>
<dt></dt>
<dd>
<del><em>Synchronization:</em>
if the object's associated state is associated with a thread object created
by a call to async (30.6.9) and no other future object refers to that
associated state, calls the member function join on the thread object.</del>
</dd>
</dl>

<p>
In 30.6.6 [futures.unique_future], paragraph 12, <code>operator=()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<ul>
  <li>if <code>*this</code> referred to an associated <ins>asynchronous</ins>
      state prior to the assignment it gives up this reference.</li>
  <li>assigns the contents of <code>rhs</code> to<code>*this</code>.</li>
</ul>
</dd>
</dl>

<p>
In 30.6.6 [futures.unique_future], paragraph 15ff, <code>get()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<ul>
 <li>
<code>wait()</code>s until the associated <ins>asynchronous</ins>
     state is ready.</li>
 <li>Retrieves the value stored in the associated <ins>asynchronous</ins>
      state.</li>
</ul>
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<ul>
 <li>
<code>future::get()</code> returns the value
     stored in the object's associated <ins>asynchronous</ins> state.</li>
 <li>The value returned shall be moved if the type of the value
     is MoveAssignable, and copied otherwise.</li>
 <li>
<code>future&lt;R&amp;&gt;::get()</code> returns the reference stored
     as value in the object's associated <ins>asynchronous</ins> state.</li>
 <li>
<code>future&lt;void&gt;::get()</code> returns nothing.</li>
</ul>
</dd>

<dt></dt>
<dd>
<em>Throws:</em>
the stored exception, if an exception was stored in the associated
<ins>asynchronous</ins> state.
</dd>
</dl>

<p>
In 30.6.6 [futures.unique_future], paragraph 19, <code>valid()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if <code>*this</code> refers to an associated
<ins>asynchronous</ins> state.
</dd>
</dl>

<p>
In 30.6.6 [futures.unique_future], paragraph 21, <code>wait()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<del>if the associated state contains a deferred function, executes
the deferred function. Otherwise,</del>
blocks until the associated <ins>asynchronous</ins> state is ready.
</dd>
</dl>



<h3>LWG issue 1244 (New)</h3>
<p>
In 30.6.6 [futures.unique_future], before paragraph 22, <code>wait_for</code>:<br>
Change:
</p>
<pre>
  template &lt;class Rep, class Period&gt;
  <del>bool</del><ins>future_status</ins> wait_for(const chrono::duration&lt;Rep, Period&gt;&amp; rel_time) const;
</pre>

<p>
In 30.6.6 [futures.unique_future], paragraph 23f, <code>wait_for</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<del>if the associated state contains a deferred function, the behavior is
unspecified. Otherwise,</del>
blocks until the associated <ins>asynchronous</ins> state is ready
or until <code>rel_time</code> has elapsed.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<del><code>true</code> only if the associated state is ready.</del>
<ins><ul>
      <li><ins><code>future_status::deferred</code> if the associated
          asynchronous state contains a deferred function that is not
          running.</ins></li>
      <li><ins><code>future_status::ready</code> if the associated
          asynchronous state is <em>ready</em>.</ins></li>
      <li><ins><code>future_status::timeout</code> if the function is
          returning because the time period specified
          by <code>rel_time</code> has elapsed.</ins></li>
</ul></ins>
</dd>
</dl>

<p>
In 30.6.6 [futures.unique_future], before paragraph 25, <code>wait_until</code>:<br>
Change:
</p>
<pre>
  template &lt;class Clock, class Duration&gt;
  <del>bool</del><ins>future_status</ins> wait_until(const chrono::time_point&lt;Clock, Duration&gt;&amp; abs_time) const;
</pre>

<p>
In 30.6.6 [futures.unique_future], paragraph 26f, <code>wait_until</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated <ins>asynchronous</ins> state is ready
or until the current time exceeds <code>abs_time</code>.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<del><code>true</code> only if the associated state is ready.</del>
<ins><ul>
      <li><ins><code>future_status::deferred</code> if the associated
          asynchronous state contains a deferred function that is not
          running.</ins></li>
      <li><ins><code>future_status::ready</code> if the associated
          asynchronous state is <em>ready</em>.</ins></li>
      <li><ins><code>future_status::timeout</code> if the function is
          returning because the time point specified
          by <code>abs_time</code> has been reached.</ins></li>
</ul></ins>
</dd>
</dl>



<h3>LWG issue 1275 (New)</h3>
<p>
In 30.6.7 [future.shared_future], paragraph 1f, introduction:<br>
Change:
</p>
<p>
The class template <code>shared_future</code> defines a type for
asynchronous return objects which may share their associated
<ins>asynchronous</ins> state <ins>with other asynchronous return objects</ins>.
A default-constructed <code>shared_future</code> has no associated
<ins>asynchronous</ins> state.
A <code>shared_future</code> object with associated <ins>asynchronous</ins>
state can <del>only</del> be created
<del>from another <code>shared_future</code> with
associated state or a <code>future</code> object with
associated state</del>
<ins>by conversion from a <code>future</code> object
and share their associated asynchronous state with the original
asynchronous provider of the associated state</ins>.
<del>Their</del><ins>The result (</ins>values or exceptions<ins>) of
<code>shared_future</code> objects</ins>
can be set by
<del>use of a <code>promise</code> ([future.promise])
or <code>packaged_task</code> ([future.task])</del>
<ins>calling a respective function on an</ins> object that
shares the same associated <ins>asynchronous</ins> state.
</p>
<p>[<em>Note:</em><code>shared_future</code> member functions do not
synchronize with themselves, but they synchronize on the shared
associated <ins>asynchronous</ins> state. --end note]
</p>
<p><ins>
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.
</ins></p>


<h3>LWG issue 1244 (New)</h3>
<p>In 30.6.7 [future.shared_future], after paragraph 2, synopsis:<br>
Change:
</p>
<pre>
  template &lt;class Rep, class Period&gt;
  <del>bool</del><ins>future_status</ins> wait_for(const chrono::duration&lt;Rep, Period&gt;&amp; rel_time) const;
  template &lt;class Clock, class Duration&gt;
  <del>bool</del><ins>future_status</ins> wait_until(const chrono::time_point&lt;Clock, Duration&gt;&amp; abs_time) const;
</pre>


<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 <ins>asynchronous</ins> state.
</dd>
<dt></dt>
<dd><ins><em>Postcondition:</em>
<code>valid() == false</code>
</ins></dd>
<dt></dt>
<dd><ins><em>Throws:</em>
nothing.
</ins></dd>
</dl>


<h3>Clean-up</h3>
<p>
In 30.6.7 [future.shared_future], paragraph 5, <code>shared_future(const shared_future&amp;)</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
constructs a <code>shared_future</code> object that refers to the same
associated <ins>asynchronous</ins> state as <code>rhs</code> (if any).
</dd>
</dl>

<p>
In 30.6.7 [future.shared_future], paragraph 7, move-ctor <code>shared_future</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
move constructs a <code>shared_future</code> object that refers to the
associated <ins>associated</ins> state that was originally referred to by
<code>rhs</code> (if any).
</dd>
</dl>

<p>
In 30.6.7 [future.shared_future], paragraph 10f, <code>~shared_future()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<ul>
  <li>gives up the reference to its associated <ins>asynchronous</ins>state.</li>
  <li>destroys <code>*this</code>.</li>
</ul>
</dd>
<dt></dt>
<dd>
<del><em>Synchronization:</em>
if the object's associated state is associated with a thread object created
by a call to async (30.6.9) and no other future object refers to that
associated state, calls the member function join on the thread object.</del>
</dd>
</dl>

<p>
In 30.6.7 [future.shared_future], paragraph 12, move-assignment:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<ul>
  <li>if <code>*this</code> referred to an associated <ins>asynchronous</ins>
      state prior to the assignment it gives up this reference.</li>
  <li>assigns the contents of <code>rhs</code> to<code>*this</code>.</li>
</ul>
</dd>
</dl>

<p>
In 30.6.7 [future.shared_future], paragraph 14, copy-assignment:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<ul>
  <li>if <code>*this</code> referred to an associated <ins>asynchronous</ins>
      state prior to the assignment it gives up this reference.</li>
  <li>assigns the contents of <code>rhs</code> to<code>*this</code>.
    [<em>Note</em>: So <code>*this</code> refers to the same associated
    <ins>asynchronous</ins>state as <code>rhs</code>
    (if any). --<em>end note</em>]</li>
</ul>
</dd>
</dl>

<p>
In 30.6.7 [future.shared_future], paragraph 18ff, <code>get()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<ul>
 <li>
<code>wait()</code>s until the associated <ins>asynchronous</ins> state
     is ready.</li>
 <li>Retrieves the value stored in the associated <ins>asynchronous</ins>
     state.</li>
</ul>
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<ul>
 <li>
<code>shared_future::get()</code> returns a const reference to the value
     stored in the object's associated <ins>asynchronous</ins> state.</li>
 <li>
<code>shared_future&lt;R&amp;&gt;::get()</code> returns the reference
      stored as value in the object's associated <ins>asynchronous</ins>
      state.</li>
 <li>
<code>future&lt;void&gt;::get()</code> returns nothing.</li>
</ul>
</dd>

<dt></dt>
<dd>
<em>Throws:</em>
the stored exception, if an exception was stored in the associated
<ins>asynchronous</ins> state.
</dd>
</dl>

<p>
In 30.6.7 [future.shared_future], paragraph 21, <code>valid()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> only if <code>*this</code> refers to an associated
<ins>asynchronous</ins> state.
</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><ins><em>Requires:</em>
<code>valid() == true</code>
</ins></dd>
<dt></dt>
<dd>
<em>Effects:</em>
<del>if the associated state contains a deferred function, executes the
deferred function. Otherwise,</del> blocks until the associated
<ins>asynchronous</ins> 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()/wait_until()</code>:<br>
Change:
</p>
<pre>
  template &lt;class Rep, class Period&gt;
  <del>bool</del><ins>future_status</ins> wait_for(const chrono::duration&lt;Rep, Period&gt;&amp; rel_time) const;
</pre>
<dl>
<dt></dt>
<dd><ins><em>Requires:</em>
<code>valid() == true</code>
</ins></dd>
<dt></dt>
<dd>
<em>Effects:</em>
<del>if the associated state contains a deferred function, the behavior is
unspecified. Otherwise,</del>
blocks until the associated <ins>asynchronous</ins> state is ready
or until <code>rel_time</code> has elapsed.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<del><code>true</code> only if the associated state is ready.</del>
<ins><ul>
      <li><ins><code>future_status::deferred</code> if the associated
          asynchronous state contains a deferred function that is not
          running.</ins></li>
      <li><ins><code>future_status::ready</code> if the associated
          asynchronous state is <em>ready</em>.</ins></li>
      <li><ins><code>future_status::timeout</code> if the function is
          returning because the time period specified
          by <code>rel_time</code> has elapsed.</ins></li>
</ul></ins>
</dd>
</dl>

<pre>
  template &lt;class Clock, class Duration&gt;
  <del>bool</del><ins>future_status</ins> wait_until(const chrono::time_point&lt;Clock, Duration&gt;&amp; abs_time) const;
</pre>

<dl>
<dt></dt>
<dd><ins><em>Requires:</em>
<code>valid() == true</code>
</ins></dd>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated <ins>asynchronous</ins> state is ready
or until the current time exceeds <code>abs_time</code>.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<del><code>true</code> only if the associated state is ready.</del>
<ins><ul>
      <li><ins><code>future_status::deferred</code> if the associated
          asynchronous state contains a deferred function that is not
          running.</ins></li>
      <li><ins><code>future_status::ready</code> if the associated
          asynchronous state is <em>ready</em>.</ins></li>
      <li><ins><code>future_status::timeout</code> if the function is
          returning because the time point specified
          by <code>abs_time</code> has been reached.</ins></li>
</ul></ins>
</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<ins> objects which may share their associated
asynchronous state with other asynchronous return objects</ins>.
<ins>A single <code>atomic_future</code> object may be shared between
different threads.</ins>
<del>These objects can only be created by use of
<code>promise</code> ([future.promise])
or <code>packaged_task</code> ([future.task]) objects.</del>
<ins>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.</ins>
<del>Their values or exceptions can be set
by use of <code>promise</code> ([future.promise]) objects.</del>
<ins>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.</ins>
</p>

<h3>LWG issue 1244 (New)</h3>
<p>In 30.6.8 [futures.atomic_future], after paragraph 2, synopsis:<br>
Change:
</p>
<pre>
  template &lt;class Rep, class Period&gt;
  <del>bool</del><ins>future_status</ins> wait_for(const chrono::duration&lt;Rep, Period&gt;&amp; rel_time) const;
  template &lt;class Clock, class Duration&gt;
  <del>bool</del><ins>future_status</ins> wait_until(const chrono::time_point&lt;Clock, Duration&gt;&amp; abs_time) const;
</pre>

<h3>Clean-up</h3>
<p>In 30.6.8 [futures.atomic_future], paragraph 3, <code>atomic_future()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
constructs an <em>empty</em> <code>atomic_future</code> that doesn't
refer to an associated <ins>asynchronous</ins> state.
</dd>
</dl>

<p>In 30.6.8 [futures.atomic_future], before paragraph 5, <code>atomic_future(const atomic_future&amp;)</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
constructs an <code>atomic_future</code> object that refers to the same
associated <ins>asynchronous</ins> state as <code>rhs</code> (if any).
</dd>
</dl>



<h3>LWG issue 1274 (Tentatively Ready)</h3>
<p>
In 30.6.8 [futures.atomic_future], before paragraph 6, <code>atomic_future(atomic_future&lt;R&gt;&amp;&amp; rhs)</code>:<br>
Change:
</p>
<pre>
atomic_future(<del>atomic_</del>future<ins>&lt;R&gt;</ins>&amp;&amp; rhs);
</pre>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
move constructs an <code>atomic_future</code> object  that refers to the
associated <ins>asynchronous</ins> state that was originally referred
to by <code>rhs</code> (if any).
</dd>
</dl>


<h3>Clean-up</h3>
<p>
In 30.6.8 [futures.atomic_future], after paragraph 6, <code>~atomic_future()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<ul>
  <li>gives up the reference to its associated <ins>asynchronous</ins> state.</li>
  <li>destroys <code>*this</code>.</li>
</ul>
</dd>
</dl>

<p>
In 30.6.8 [futures.atomic_future], paragraph 7ff, <code>operator=()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd><del><em>Requires:</em>
<code>valid() == false</code>
</del></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
<ins>asynchronous</ins> 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 <del>the left-hand side</del>
<ins><code>*this</code></ins>.
</dd>
</dl>

<p>
In 30.6.8 [futures.atomic_future], paragraph 13ff, <code>get()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd><del><em>Requires:</em>
<code>valid() == true</code>
</del></dd>
<dt></dt>
<dd>
<em>Effects:</em>
<ul>
 <li>
<code>wait()</code>s until the associated <ins>asynchronous</ins>
     state is ready.</li>
 <li>Retrieves the value stored in the associated <ins>asynchronous</ins>
     state.</li>
</ul>
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<ul>
 <li>
<code>atomic_future::get()</code> returns a const reference to the
     value stored in the object's associated <ins>asynchronous</ins> state.</li>
 <li>
<code>atomic_future&lt;R&amp;&gt;::get()</code> returns the reference
      stored as value in the object's associated <ins>asynchronous</ins> state.</li>
 <li>
<code>atomic_future&lt;void&gt;::get()</code> returns nothing.</li>
</ul>
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
<ul>
  <li>the exception in the object's associated <ins>asynchronous</ins> state,
      if an exception was stored there, or</li>
  <li>
<code>future_error</code> <ins>if an error condition occurs.</ins>
</li>
</ul>
</dd>
<dt></dt>
<dd>
<ins><em>Error condition:</em></ins>
<del>with an error condition of</del>
<code>no_state</code> if <del>the precondition is not met</del>
<ins><code>valid() == false</code></ins>.
</dd>
<dt></dt>
<dd>[<em>Note:</em>:
Contrary to <code>future</code>, calling <code>get()</code>
more than once on the same object is well defined and just produces
the result again. --<em>end note</em>]
</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>Requires:</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 <ins>asynchronous</ins> state is ready.
</dd>
<dt></dt>
<dd><ins><em>Throws:</em>
<code>future_error</code> if an error condition occurs.
</ins></dd>
<dt></dt>
<dd>
<ins><em>Error conditions:</em>
<ul>
  <li>
    <ins><code>no_state</code> &mdash; if <code>*this</code> has no
    associated asynchronous state.</ins>
  </li>
</ul></ins>
</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()/wait_until()</code>:<br>
Change:
</p>
<pre>
  template &lt;class Rep, class Period&gt;
  <del>bool</del><ins>future_status</ins> wait_for(const chrono::duration&lt;Rep, Period&gt;&amp; rel_time) const;
</pre>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated <ins>asynchronous</ins> state is ready
or until <code>rel_time</code> has elapsed.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<del><code>true</code> only if the associated state is ready.</del>
<ins><ul>
      <li><ins><code>future_status::deferred</code> if the associated
          asynchronous state contains a deferred function that is not
          running.</ins></li>
      <li><ins><code>future_status::ready</code> if the associated
          asynchronous state is <em>ready</em>.</ins></li>
      <li><ins><code>future_status::timeout</code> if the function is
          returning because the time period specified
          by <code>rel_time</code> has elapsed.</ins></li>
</ul></ins>
</dd>
<dt></dt>
<dd><ins><em>Throws:</em>
<code>future_error</code> if an error condition occurs.
</ins></dd>
<dt></dt>
<dd><ins><em>Error condition:</em>
<code>no_state</code> if <code>*this</code> has no associated asynchronous
state.
</ins></dd>
</dl>

<pre>
  template &lt;class Clock, class Duration&gt;
  <del>bool</del><ins>future_status</ins> wait_until(const chrono::time_point&lt;Clock, Duration&gt;&amp; abs_time) const;
</pre>

<dl>
<dt></dt>
<dd>
<em>Effects:</em>
blocks until the associated <ins>asynchronous</ins> state is ready
or until the current time exceeds <code>abs_time</code>.
</dd>
<dt></dt>
<dd>
<em>Returns:</em>
<del><code>true</code> only if the associated state is ready.</del>
<ins><ul>
      <li><ins><code>future_status::deferred</code> if the associated
          asynchronous state contains a deferred function that is not
          running.</ins></li>
      <li><ins><code>future_status::ready</code> if the associated
          asynchronous state is <em>ready</em>.</ins></li>
      <li><ins><code>future_status::timeout</code> if the function is
          returning because the time point specified
          by <code>abs_time</code> has been reached.</ins></li>
</ul></ins>
</dd>
<dt></dt>
<dd><ins><em>Throws:</em>
<code>future_error</code> if an error condition occurs.
</ins></dd>
<dt></dt>
<dd><ins><em>Error condition:</em>
<code>no_state</code> if <code>*this</code> has no associated asynchronous
state.
</ins></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 <del>F::result_type</del><ins>result_of&lt;F(Args...)&gt;::type</ins>&gt;
      async(F&amp;&amp; f, Args&amp;&amp;... args);
    template &lt;class F, class... Args&gt;
      future&lt;typename <del>F::result_type</del><ins>result_of&lt;F(Args...)&gt;::type</ins>&gt;
      async(launch policy, F&amp;&amp; f, Args&amp;&amp;... args);
</pre>

<h3>Clean-Up</h3>
<p>
In 30.6.9 [futures.async], paragraph 1, <code>async()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Requires:</em>
<code>F</code> and each <code>Ti</code> in <code>Args</code> shall
<del>be <code>CopyConstructible</code> if an lvalue and otherwise</del>
<ins>satisfy the</ins> <code>MoveConstructible</code> <ins>requirements</ins>.
<del><code>INVOKE(f, w1, w2, ..., wN)</code> (20.7.2 [func.require]) shall be
a valid expression for some values <code>w1, w2, ... , wN</code>,
where <code>N == sizeof...(Args).</code></del>
<ins><code>INVOKE(decay_copy(std::forward&lt;F&gt;(f)),
decay_copy(std::forward&lt;Args&gt;(args))...)</code> (20.7.2 [func.require],
30.3.1.2 [thread.thread.constr]) shall be a valid expression.</ins>"
</dd>
<dt></dt>
<dd>&nbsp;</dd>
<dt></dt>
<dd>
<ins>
<em>Effects:</em>
</ins>
<del><em>Returns:</em>
an object of type <code>future&lt;typename F::result_type&gt;</code>.</del>
</dd>
<dt></dt>
<dd>
The first function behaves the same as a call to the second function
with a policy argument of <code>launch::any</code> and the same arguments for
<code>F</code> and <code>Args</code>.
<ins>The second function creates an associated asynchronous state that is
associated with the returned <code>future</code> object.</ins>
The <ins>further</ins> behavior of the second function depends on the
policy argument as follows:
</dd>
<dt></dt>
<dd>
<ul>
  <li>
    <code>launch::async</code> &mdash; executes
<del><code>INVOKE (f, w1, w2, ..., wN)</code></del>
<ins><code>INVOKE(decay_copy(std::forward&lt;F&gt;(f)), decay_copy(std::forward&lt;Args&gt;(args))...)</code></ins>
as if in a new thread of execution represented by a thread object
<ins>with the calls to <code>decay_copy()</code> being evaluated in the
thread that called <code>async</code></ins>.
Any return value is <del>captured by the <code>future</code> object</del>
<ins>stored as the result in the associated asynchronous state</ins>.
Any exception propagated from <del><code>f</code></del>
<ins>the execution of
<code>INVOKE(decay_copy(std::forward&lt;F&gt;(f)), decay_copy(std::forward&lt;Args&gt;(args))...)</code></ins>
is <del>captured by the <code>future</code> object</del>
<ins>stored as the exceptional result in the associated asynchronous
state</ins>.
The thread object is <del>associated with the <code>future</code> object</del>
<ins>stored in the associated asynchronous state</ins> and affects the
behavior of <del>the <code>future</code> object</del>
<ins>any <code>future</code> objects that reference that state</ins>.</li>
  <li>
<code>launch::sync</code>
      &mdash; <del><code>INVOKE (f, w1, w2, ..., wN)</code>
      is associated with the <code>future</code> object.
      The invocation is said to be deferred.</del>
      <ins>Stores <code>decay_copy(std::forward&lt;F&gt;(f))</code> and
      <code>decay_copy(std::forward&lt;Args&gt;(args))...</code> in the
      associated asynchronous state. These copies of <code>f</code> and
      <code>args</code> constitute a deferred function. Invocation of
      the deferred function evaluates <code>INVOKE(g,xyz)</code> where
      <code>g</code> is the stored value of
      <code>decay_copy(std::forward&lt;F&gt;(f))</code> and <code>xyz</code>
      is the stored copy of
      <code>decay_copy(std::forward&lt;Args&gt;(args))...</code>
      The associated asynchronous state is not ready until the
      function has completed.
      The first call to a function waiting for the associated asynchronous
      state created by this <code>async()</code> call to become ready
      shall invoke the deferred function in the thread that called the
      waiting function;
      all other calls waiting for the same associated asynchronous state to
      become ready shall block until the deferred function has completed.
</ins>
</li>
  <li>
<code>launch::any</code> &mdash; the implementation may choose either
      <del>either</del> policy above at any call to <code>async</code>.
      [Note: implementations should defer invocations when no more concurrency
      can be effectively exploited.  --end note ]</li>
</ul>
</dd>
<dt></dt>
<dd>&nbsp;</dd>
<dt></dt>
<dd>
<ins><em>Returns:</em>
an object of type <code>future&lt;typename result_of&lt;F(Args...)&gt;::type&gt;</code>
that refers to the associated asynchronous state created by this call to <code>async</code></ins>.
</dd>
<dt></dt>
<dd>&nbsp;</dd>
<dt></dt>
<dd>
<em>Synchronization:</em>
the invocation of <del>the</del> <code>async</code> happens-before
([intro.multithread]) the invocation of <code>f</code>.
[Note: this statement applies even when the corresponding <code>future</code>
object is moved to another thread. --end note ]
</dd>
<dt></dt>
<dd><ins>
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.
</ins></dd>
<dt></dt>
<dd><ins>
If the invocation is not deferred, the <code>join()</code> on the created
thread happens-before [intro.multithread] the first function that successfully
detects the ready status of the associated asynchronous state returns
or before the function that gives up the last reference to the
associated asynchronous state returns, whichever happens first.
</ins></dd>
<dt></dt>
<dd><ins>
If the invocation is deferred, the completion of the invocation of the
deferred function happens-before the calls to the waiting functions return.
</ins></dd>
</dl>

<p>
In 30.6.9 [futures.async], paragraph 5:<br>
Change:
</p>
<dl>
<em>Error conditions:</em>
<ul>
  <li>
    <code>resource_unavailable_try_again</code> &mdash; if <code>policy</code>
    is <code>launch::async</code> and <del>either the system lacked
    the necessary resources to create another thread or the system-imposed
    limit on the number of threads in a process would be exceeded.</del>
    <ins>the implementation is unable to start a new thread</ins>
  </li>
</ul>
</dl>


<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>Clean-up</h3>
<p>
In 30.6.10 [futures.futures_task], paragraph 1, introduction:<br>
Change:
</p>
<p>
A <code>packaged_task</code> provides a means of wrapping a
function or callable object so that the return value of the function
or callable object is stored in a <code>future</code> when it is invoked.
<del>The associated state of a <code>packaged_task</code> object includes
storage for a copy of this associated task.</del>
</p>
<p>
When the <code>packaged_task</code> is invoked, its <del>associated</del>
<ins>stored</ins> task is invoked, and the result (whether normal or
exceptional) stored in the associated <ins>asynchronous</ins> state.
Any futures that shares the associated <ins>asynchronous</ins> state
will then be able to access the stored result.
</p>


<h3>LWG issue 1090 (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>

<h3>Clean-up</h3>
<p>
In 30.6.10 [futures.futures_task], paragraph 4, <code>packaged_task()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
constructs a <code>packaged_task</code> object with no
associated <ins>asynchronous</ins> state <ins>n</ins>or <ins>stored</ins> task.
</dd>
</dl>

<p>
In 30.6.10 [futures.futures_task], paragraph 6f, ctor:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<ins><em>Requires:</em></ins>
<code>INVOKE (f, t1, t2, ..., tN, R)</code>
where <code>t1</code>, <code>t2</code>, ..., <code>tN</code> are
values of the corresponding types in <code>ArgTypes....</code>
shall be a valid expression. Invoking a copy of <code>f</code>
shall behave the same as invoking <code>f</code>.
</dd>

<dt></dt>
<dd>
<em>Effects:</em>
constructs a new <code>packaged_task</code> object <ins>and stores</ins>
<del>with</del> a copy of <code>f</code> <del>stored in the associated state</del>
as the object's <del>associated</del><ins>stored</ins> task.
<ins>And constructs an associated asynchronous state.</ins>
The constructors that take an <code>Allocator</code>
argument use it to allocate memory needed to store the internal data
structures.
</dd>
</dl>

<p>
In 30.6.10 [futures.futures_task], paragraph 9f, move-ctor:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
constructs a new <code>packaged_task</code>
object and transfers <code>other</code>'s stored task and
ownership of <code>other</code>'s associated
<ins>asynchronous</ins> state to <code>*this</code>,
leaving <code>other</code> with no associated <ins>asynchronous</ins> state.
</dd>
<dt></dt>
<dd>
<em>Postcondition:</em>
<code>other</code> has no associated <ins>asynchronous</ins> state.
</dd>
<dt></dt>
<dd>
<em>Throws:</em> nothing.
</dd>
</dl>

<p>
In 30.6.10 [futures.futures_task], paragraph 13, <code>~packaged_task()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
If the <ins>asynchronous</ins> state associated with <code>*this</code> is
not ready, stores an exception of type <code>future_error</code> with an
error <del>code</del><ins>condition</ins> of <code>broken_promise</code>.
Any threads blocked in a <del>member</del> function
<del>of <code>future</code>, <code>shared_future</code>
or <code>atomic_future</code></del> waiting for the <ins>asynchronous</ins>
state associated
with <code>*this</code> to become <em>ready</em> are unblocked.
</dd>
<dt></dt>
<dd>
Destroys <code>*this</code> <ins>and the stored task, if any,</ins> and releases its
reference to its associated <ins>asynchronous</ins> state if any.
If this is the last reference to that associated <ins>asynchronous</ins>
state, destroys that state.
</dd>
</dl>

<p>
In 30.6.10 [futures.futures_task], paragraph 15f, <code>swap()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
exchanges the associated <ins>asynchronous</ins> states <ins>and stored
tasks</ins> of <code>*this</code> and <code>other</code>.
</dd>
<dt></dt>
<dd>
<em>Postcondition:</em>
<code>*this</code> has the same associated <ins>asynchronous</ins> state
<ins>and stored task</ins> (if any)
as <code>other</code> prior to the call
to <code>swap</code>. <code>other</code> has the same associated
<ins>asynchronous</ins> state <ins>and stored task</ins> (if any) as
<code>*this</code> prior to the call
to <code>swap</code>.
</dd>
</dl>

<p>
In 30.6.10 [futures.futures_task], paragraph 18, <code>operator bool()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Returns:</em>
<code>true</code> if and only if <code>*this</code> has an associated
<ins>asynchronous</ins> state.
</dd>
</dl>

<p>
In 30.6.10 [futures.futures_task], paragraph 20ff, <code>get_future()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Returns:</em>
a <code>future</code> object that
shares the same associated <ins>asynchronous</ins> state as <code>*this</code>.
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
<code>std::future_error</code> if an error occurs.
</dd>
<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
<code>future_already_retrieved</code> if <code>get_future</code>
    has already been called on
    a <code>packaged_task</code> with the associated <ins>asynchronous</ins>
    state of <code>*this</code>.</li>
  <li>
<code>no_state</code> if <code>*this</code> has no associated
    <ins>asynchronous</ins> state.</li>
</ul>
</dd>
</dl>

<p>
In 30.6.10 [futures.futures_task], paragraph 20ff, <code>operator()()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
<code>INVOKE (f, t1, t2, ..., tN, R)</code>,
where <code>f</code> is the <ins>stored</ins> task <del>in associated state</del>
of <code>*this</code> and <code>t1</code>, <code>t2</code>,
..., <code>tN</code> are the values in <code>args...</code>. If
the task returns normally, the return value is stored as the
asynchronous result in the <ins>asynchronous</ins> state associated
with <code>*this</code>, otherwise the exception thrown by the
task is stored. The <ins>asynchronous</ins> state associated with
<code>*this</code> is
made <em>ready</em>, and any threads blocked in a <del>member</del> function
<del>of <code>future</code>, <code>shared_future</code>
or <code>atomic_future</code></del> waiting for the <ins>asynchronous</ins>
state associated
with <code>*this</code> to become <em>ready</em> are
unblocked.
</dd>
<dt></dt>
<dd>
<em>Throws:</em>
<code>std::future_error</code> if there is no
  associated <ins>asynchrounous</ins> state or the <ins>stored</ins> task
has already been invoked.
</dd>
<dt></dt>
<dd>
<em>Error conditions:</em>
<ul>
  <li>
<code>no_state</code> if <code>*this</code> has no associated
    <ins>asynchronous</ins> state.</li>
  <li>
<code>promise_already_satisfied</code> if the associated
    <ins>asynchronous</ins> state is already <em>ready</em>.</li>
</ul>
</dd>
<dt></dt>
<dd>
<em>Synchronization:</em>
A successful call to <code>operator()</code> synchronizes with
([intro.multithread]) a call to any member function of
a <code>future</code> object, <code>shared_future</code>
object or <code>atomic_future</code> object that shares the same
associated <ins>asynchronous</ins> state.
The completion of the invocation of the
<del>associated</del><ins>stored</ins> task and the storage of the result
(whether normal or
exceptional) into the associated <ins>asynchronous</ins>  state happens-before
([intro.multithread]) that state is set to <em>ready</em>.
</dd>
<dt></dt>
<dd>[<em>Note</em>:
<code>operator()</code> synchronizes and serializes with other functions
through the referred associated <ins>asynchronous</ins> state. --<em>end note</em>]
</dd>
</dl>

<p>
In 30.6.10 [futures.futures_task], paragraph 27f, <code>reset()</code>:<br>
Change:
</p>
<dl>
<dt></dt>
<dd>
<em>Effects:</em>
returns the object to a state as if a
newly-constructed instance had just been assigned to
<code>*this</code> by <code>*this = packaged_task(std::move(f))</code>,
where <code>f</code> is the task
stored in <del>the associated state of</del> <code>*this</code>.
</dd>
<dt></dt>
<dd>
[<em>Note:</em> This constructs a new associated <ins>asynchronous</ins> state
for <code>*this</code>. The old state is discarded, as described in
the destructor
for <code>packaged_task</code>. <code>get_future()</code> may now be
called again for <code>*this</code>. -- <em>end note</em>]
</dd>

<dt></dt>
<dd>
<em>Throws:</em>
<ul>
  <li>
<code>std::bad_alloc</code> if memory for the <del>new
    associated state</del><ins>internal data structures</ins>
    could not be allocated.</li>
  <li>Any exception thrown by the copy constructor of the task
    stored in <del>the associated state</del><ins><code>*this</code></ins>.</li>
  <li>
<code>std::future_error</code> with an error condition
    of <code>no_state</code> if <code>*this</code> has no
    associated <ins>asynchronous</ins> state</li>
</ul>
</dd>
</dl>



<h3>LWG issue 1090 (Ready)</h3>
<p>
In 30.6.10 [futures.futures_task], after paragraph 28 (at the end):<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>
