Commit 0dc3cba1 by Jonathan Wakely Committed by Jonathan Wakely

re PR libstdc++/65393 (std::thread shared_ptr inefficiency)

	PR libstdc++/65393
	* src/c++11/thread.cc (thread::_M_make_thread): Replace shared_ptr
	copies with moves.

From-SVN: r224530
parent b2c15a77
2015-06-16 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/65393
* src/c++11/thread.cc (thread::_M_make_thread): Replace shared_ptr
copies with moves.
2015-06-12 Jonathan Wakely <jwakely@redhat.com> 2015-06-12 Jonathan Wakely <jwakely@redhat.com>
* include/precompiled/stdc++.h: Include <codecvt> and <shared_mutex>. * include/precompiled/stdc++.h: Include <codecvt> and <shared_mutex>.
......
...@@ -92,7 +92,7 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -92,7 +92,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
std::terminate(); std::terminate();
} }
return 0; return nullptr;
} }
} }
...@@ -137,18 +137,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -137,18 +137,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__throw_system_error(int(errc::operation_not_permitted)); __throw_system_error(int(errc::operation_not_permitted));
#endif #endif
_M_start_thread(__b, nullptr); _M_start_thread(std::move(__b), nullptr);
} }
void void
thread::_M_start_thread(__shared_base_type __b, void (*)()) thread::_M_start_thread(__shared_base_type __b, void (*)())
{ {
__b->_M_this_ptr = __b; auto ptr = __b.get();
ptr->_M_this_ptr = std::move(__b);
int __e = __gthread_create(&_M_id._M_thread, int __e = __gthread_create(&_M_id._M_thread,
&execute_native_thread_routine, __b.get()); &execute_native_thread_routine, ptr);
if (__e) if (__e)
{ {
__b->_M_this_ptr.reset(); ptr->_M_this_ptr.reset();
__throw_system_error(__e); __throw_system_error(__e);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment