Author: marshall
Date: Sun Nov  3 09:43:35 2013
New Revision: 193960

URL: http://llvm.org/viewvc/llvm-project?rev=193960&view=rev
Log:
Fix LWG Issue 2078. Make std::async(policy,...) try multiple policies until one 
succeeds.

Modified:
    libcxx/trunk/include/future
    libcxx/trunk/www/cxx1y_status.html

Modified: libcxx/trunk/include/future
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=193960&r1=193959&r2=193960&view=diff
==============================================================================
--- libcxx/trunk/include/future (original)
+++ libcxx/trunk/include/future Sun Nov  3 09:43:35 2013
@@ -2331,20 +2331,32 @@ private:
     }
 };
 
+bool __does_policy_contain(launch __policy, launch __value )
+{ return (int(__policy) & int(__value)) != 0; }
+
 template <class _Fp, class... _Args>
 future<typename __invoke_of<typename decay<_Fp>::type, typename 
decay<_Args>::type...>::type>
 async(launch __policy, _Fp&& __f, _Args&&... __args)
 {
     typedef __async_func<typename decay<_Fp>::type, typename 
decay<_Args>::type...> _BF;
     typedef typename _BF::_Rp _Rp;
-    future<_Rp> __r;
-    if (int(__policy) & int(launch::async))
-        __r = 
_VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)),
+
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif
+        if (__does_policy_contain(__policy, launch::async))
+        return 
_VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)),
                                                      
__decay_copy(_VSTD::forward<_Args>(__args))...));
-    else if (int(__policy) & int(launch::deferred))
-        __r = 
_VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)),
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch ( ... ) { if (__policy == launch::async) throw ; }
+#endif
+
+    if (__does_policy_contain(__policy, launch::deferred))
+        return 
_VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)),
                                                         
__decay_copy(_VSTD::forward<_Args>(__args))...));
-    return __r;
+    return future<_Rp>{};
 }
 
 template <class _Fp, class... _Args>

Modified: libcxx/trunk/www/cxx1y_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1y_status.html?rev=193960&r1=193959&r2=193960&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1y_status.html (original)
+++ libcxx/trunk/www/cxx1y_status.html Sun Nov  3 09:43:35 2013
@@ -196,7 +196,7 @@
        <tr><td><a 
href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2194";>2194</a></td><td>Impossible
 container requirements for adaptor 
types</td><td>Chicago</td><td>Complete</td></tr>
        <tr><td><a 
href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2013";>2013</a></td><td>Do
 library implementers have the freedom to add 
constexpr?</td><td>Chicago</td><td>Complete</td></tr>
        <tr><td><a 
href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2018";>2018</a></td><td>regex_traits::isctype
 Returns clause is wrong</td><td>Chicago</td><td>Complete</td></tr>
-       <tr><td><a 
href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2078";>2078</a></td><td>Throw
 specification of async() incomplete</td><td>Chicago</td><td></td></tr>
+       <tr><td><a 
href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2078";>2078</a></td><td>Throw
 specification of async() incomplete</td><td>Chicago</td><td>Complete</td></tr>
        <tr><td><a 
href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2097";>2097</a></td><td>packaged_task
 constructors should be constrained</td><td>Chicago</td><td>Complete</td></tr>
        <tr><td><a 
href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2100";>2100</a></td><td>Timed
 waiting functions cannot timeout if launch::async policy 
used</td><td>Chicago</td><td>Complete</td></tr>
        <tr><td><a 
href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2120";>2120</a></td><td>What
 should async do if neither 'async' nor 'deferred' is set in 
policy?</td><td>Chicago</td><td>Complete</td></tr>


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to