This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[patch] libstdc++/56117 make std::async launch new threads by default
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 2 May 2015 19:56:27 +0100
- Subject: [patch] libstdc++/56117 make std::async launch new threads by default
- Authentication-results: sourceware.org; auth=none
One last patch before I head to Lenexa, this fixes the long standing
not-a-bug that our default launch policy is launch::deferred.
This way std::async with no explicit policy or with any policy that
contains launch::async will run in a new thread.
Apparently libc++ does the same and they aren't getting lots of
complaints about fork-bombs, so let's try the same thing. If people
don't like it we have plenty of time in stage 1 to reconsider.
Tested x86_64-linux and powerpc64le-linux, I'm going to commit this to
trunk unless someone strongly objects.
commit cb6dfe604295873cebd5b3a53b10b1e882eb3cff
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Sat May 2 19:27:10 2015 +0100
PR libstdc++/51617
* include/std/future (async): Change default policy to launch::async.
diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index fc3f816..a67db98 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -1704,7 +1704,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef typename result_of<_Fn(_Args...)>::type result_type;
std::shared_ptr<__future_base::_State_base> __state;
- if ((__policy & (launch::async|launch::deferred)) == launch::async)
+ if ((__policy & launch::async) == launch::async)
{
__state = __future_base::_S_make_async_state(std::__bind_simple(
std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));