summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/include/future20
-rw-r--r--libcxx/include/type_traits2
-rw-r--r--libcxx/test/thread/futures/futures.async/async.pass.cpp6
-rw-r--r--libcxx/test/thread/futures/futures.overview/launch.pass.cpp10
4 files changed, 19 insertions, 19 deletions
diff --git a/libcxx/include/future b/libcxx/include/future
index be975f48841..f51ccb90316 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -27,9 +27,9 @@ enum class future_errc
enum class launch
{
- any,
- async,
- sync
+ async = 1,
+ deferred = 2,
+ any = async | deferred
};
enum class future_status
@@ -470,9 +470,9 @@ struct _LIBCPP_VISIBLE is_error_code_enum<future_errc> : public true_type {};
struct _LIBCPP_VISIBLE launch
{
enum _ {
- any,
- async,
- sync
+ async = 1,
+ deferred = 2,
+ any = async | deferred
};
_ __v_;
@@ -2111,16 +2111,16 @@ async(launch __policy, _F&& __f, _Args&&... __args)
{
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;
}
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 7cfdbf388ad..a1e00d54277 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -1395,7 +1395,7 @@ public:
};
template <class _MP, class _Tp, class ..._Args>
-struct __result_of_mp;
+struct __result_of_mp {};
// member function pointer
diff --git a/libcxx/test/thread/futures/futures.async/async.pass.cpp b/libcxx/test/thread/futures/futures.async/async.pass.cpp
index 16565e7e605..697eb089c62 100644
--- a/libcxx/test/thread/futures/futures.async/async.pass.cpp
+++ b/libcxx/test/thread/futures/futures.async/async.pass.cpp
@@ -82,7 +82,7 @@ int main()
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 @@ int main()
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 @@ int main()
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();
diff --git a/libcxx/test/thread/futures/futures.overview/launch.pass.cpp b/libcxx/test/thread/futures/futures.overview/launch.pass.cpp
index 1e6a92fc23d..63eebe9f2d7 100644
--- a/libcxx/test/thread/futures/futures.overview/launch.pass.cpp
+++ b/libcxx/test/thread/futures/futures.overview/launch.pass.cpp
@@ -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, "");
}
OpenPOWER on IntegriCloud