[cfe-commits] [libcxx] r120027 - in /libcxx/trunk: include/future include/type_traits test/thread/futures/futures.async/async.pass.cpp test/thread/futures/futures.overview/launch.pass.cpp

Howard Hinnant hhinnant at apple.com
Tue Nov 23 10:33:54 PST 2010


Author: hhinnant
Date: Tue Nov 23 12:33:54 2010
New Revision: 120027

URL: http://llvm.org/viewvc/llvm-project?rev=120027&view=rev
Log:
N3188 - Revision to N3113: Async Launch Policies (CH 36)

Modified:
    libcxx/trunk/include/future
    libcxx/trunk/include/type_traits
    libcxx/trunk/test/thread/futures/futures.async/async.pass.cpp
    libcxx/trunk/test/thread/futures/futures.overview/launch.pass.cpp

Modified: libcxx/trunk/include/future
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=120027&r1=120026&r2=120027&view=diff
==============================================================================
--- libcxx/trunk/include/future (original)
+++ libcxx/trunk/include/future Tue Nov 23 12:33:54 2010
@@ -27,9 +27,9 @@
 
 enum class launch
 {
-    any,
-    async,
-    sync
+    async = 1,
+    deferred = 2,
+    any = async | deferred
 };
 
 enum class future_status
@@ -470,9 +470,9 @@
 struct _LIBCPP_VISIBLE launch
 {
 enum _ {
-    any,
-    async,
-    sync
+    async = 1,
+    deferred = 2,
+    any = async | deferred
 };
 
     _ __v_;
@@ -2111,16 +2111,16 @@
 {
     typedef typename result_of<_F(_Args...)>::type _R;
     future<_R> __r;
-    if (__policy == launch::sync)
-        __r = _STD::__make_deferred_assoc_state<_R>(bind(_STD::forward<_F>(__f),
-                                               _STD::forward<_Args>(__args)...));
-    else
+    if (__policy & launch::async)
     {
         packaged_task<_R()> __pk(bind(_STD::forward<_F>(__f),
                                       _STD::forward<_Args>(__args)...));
         __r = __pk.get_future();
         thread(_STD::move(__pk)).detach();
     }
+    else if (__policy & launch::deferred)
+        __r = _STD::__make_deferred_assoc_state<_R>(bind(_STD::forward<_F>(__f),
+                                              _STD::forward<_Args>(__args)...));
     return __r;
 }
 

Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=120027&r1=120026&r2=120027&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Nov 23 12:33:54 2010
@@ -1395,7 +1395,7 @@
 };
 
 template <class _MP, class _Tp, class ..._Args>
-struct __result_of_mp;
+struct __result_of_mp {};
 
 // member function pointer
 

Modified: libcxx/trunk/test/thread/futures/futures.async/async.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/thread/futures/futures.async/async.pass.cpp?rev=120027&r1=120026&r2=120027&view=diff
==============================================================================
--- libcxx/trunk/test/thread/futures/futures.async/async.pass.cpp (original)
+++ libcxx/trunk/test/thread/futures/futures.async/async.pass.cpp Tue Nov 23 12:33:54 2010
@@ -82,7 +82,7 @@
         assert(t1-t0 < ms(100));
     }
     {
-        std::future<int> f = std::async(std::launch::sync, f0);
+        std::future<int> f = std::async(std::launch::deferred, f0);
         std::this_thread::sleep_for(ms(300));
         Clock::time_point t0 = Clock::now();
         assert(f.get() == 3);
@@ -115,7 +115,7 @@
         assert(t1-t0 < ms(100));
     }
     {
-        std::future<int&> f = std::async(std::launch::sync, f1);
+        std::future<int&> f = std::async(std::launch::deferred, f1);
         std::this_thread::sleep_for(ms(300));
         Clock::time_point t0 = Clock::now();
         assert(&f.get() == &i);
@@ -148,7 +148,7 @@
         assert(t1-t0 < ms(100));
     }
     {
-        std::future<void> f = std::async(std::launch::sync, f2);
+        std::future<void> f = std::async(std::launch::deferred, f2);
         std::this_thread::sleep_for(ms(300));
         Clock::time_point t0 = Clock::now();
         f.get();

Modified: libcxx/trunk/test/thread/futures/futures.overview/launch.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/thread/futures/futures.overview/launch.pass.cpp?rev=120027&r1=120026&r2=120027&view=diff
==============================================================================
--- libcxx/trunk/test/thread/futures/futures.overview/launch.pass.cpp (original)
+++ libcxx/trunk/test/thread/futures/futures.overview/launch.pass.cpp Tue Nov 23 12:33:54 2010
@@ -11,16 +11,16 @@
 
 // enum class launch
 // {
-//     any,
-//     async,
-//     sync
+//     async = 1,
+//     deferred = 2,
+//     any = async | deferred
 // };
 
 #include <future>
 
 int main()
 {
-    static_assert(std::launch::any == 0, "");
+    static_assert(std::launch::any == std::launch::async | std::launch::deferred, "");
     static_assert(std::launch::async == 1, "");
-    static_assert(std::launch::sync == 2, "");
+    static_assert(std::launch::deferred == 2, "");
 }





More information about the cfe-commits mailing list