diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-01-29 19:10:25 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-01-29 19:10:25 +0000 |
commit | 1b927e1cb81240f4d6c73eb7cdec45246f6a3c72 (patch) | |
tree | 56e5cd4a6dc56809fa98da6b09135f74ba2ad785 /libstdc++-v3/include/std/thread | |
parent | 87e27de18fdbc0c21dcbc3108b52cdea8183acad (diff) | |
download | gcc-1b927e1cb81240f4d6c73eb7cdec45246f6a3c72.tar.gz |
2009-01-29 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk r143767
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@143769 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/std/thread')
-rw-r--r-- | libstdc++-v3/include/std/thread | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread index 00fb018989f..e6ce0f71876 100644 --- a/libstdc++-v3/include/std/thread +++ b/libstdc++-v3/include/std/thread @@ -65,7 +65,7 @@ namespace std __thread_data_base() = default; virtual ~__thread_data_base() = default; - virtual void __run() = 0; + virtual void _M_run() = 0; __gthread_t _M_thread_handle; __thread_data_ptr _M_this_ptr; @@ -80,7 +80,7 @@ namespace std : _M_func(std::forward<_Callable>(__f)) { } - void __run() + void _M_run() { _M_func(); } private: @@ -100,21 +100,29 @@ namespace std template<typename _Callable> explicit thread(_Callable __f) - : _M_thread_data(__make_thread_data(__f)) - { __start_thread(); } + : _M_thread_data(_M_make_thread_data(__f)) + { _M_start_thread(); } template<typename _Callable, typename... _Args> thread(_Callable&& __f, _Args&&... __args) - : _M_thread_data(__make_thread_data(std::bind(__f, __args...))) - { __start_thread(); } + : _M_thread_data(_M_make_thread_data(std::bind(__f, __args...))) + { _M_start_thread(); } ~thread() { detach(); } thread(const thread&) = delete; - thread(thread&&); + thread(thread&& __t) + { swap(__t); } + thread& operator=(const thread&) = delete; - thread& operator=(thread&&); + thread& operator=(thread&& __t) + { + if (joinable()) + detach(); + swap(__t); + return *this; + } // members void @@ -150,17 +158,17 @@ namespace std private: template<typename _Callable> __thread_data_ptr - __make_thread_data(_Callable&& __f) + _M_make_thread_data(_Callable&& __f) { return __thread_data_ptr( new __thread_data<_Callable>(std::forward<_Callable>(__f))); } __thread_data_ptr - __make_thread_data(void(*__f)()) + _M_make_thread_data(void(*__f)()) { return __thread_data_ptr(new __thread_data<void(*)()>(__f)); } - void __start_thread(); + void _M_start_thread(); __thread_data_ptr _M_thread_data; mutable mutex _M_thread_data_mutex; |