Commit 8644ecf5 by Chris Fairles

thread (__thread_data_base): Nest class in std::thread.

2009-02-05  Chris Fairles  <cfairles@gcc.gnu.org>
            Benjamin Kosnik  <bkoz@redhat.com>

        * include/std/thread (__thread_data_base): Nest class in std::thread.
        (__thread_data): Likewise.
        (__thread_data_ptr): Nest typedef in std::thread.
        * src/thread.cc (__thread_proxy): Qualify the above names.
        * config/abi/pre/gnu.ver: Remove unused exports.


Co-Authored-By: Benjamin Kosnik <bkoz@redhat.com>

From-SVN: r143969
parent ee04b574
2009-02-05 Chris Fairles <cfairles@gcc.gnu.org>
Benjamin Kosnik <bkoz@redhat.com>
* include/std/thread (__thread_data_base): Nest class in std::thread.
(__thread_data): Likewise.
(__thread_data_ptr): Nest typedef in std::thread.
* src/thread.cc (__thread_proxy): Qualify the above names.
* config/abi/pre/gnu.ver: Remove unused exports.
2009-02-04 Benjamin Kosnik <bkoz@redhat.com> 2009-02-04 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/unique_ptr.h: Remove private __this_type typedef. * include/bits/unique_ptr.h: Remove private __this_type typedef.
......
...@@ -897,9 +897,6 @@ GLIBCXX_3.4.11 { ...@@ -897,9 +897,6 @@ GLIBCXX_3.4.11 {
_ZNSt22condition_variable_anyD2Ev; _ZNSt22condition_variable_anyD2Ev;
# thread # thread
_ZNSt10shared_ptrISt18__thread_data_baseED1Ev;
_ZNSt12bad_weak_ptrD0Ev;
_ZNSt12bad_weak_ptrD1Ev;
_ZNSt6thread15_M_start_threadEv; _ZNSt6thread15_M_start_threadEv;
_ZNSt6thread4joinEv; _ZNSt6thread4joinEv;
_ZNSt6thread6detachEv; _ZNSt6thread6detachEv;
......
...@@ -53,41 +53,25 @@ ...@@ -53,41 +53,25 @@
namespace std namespace std
{ {
class __thread_data_base; class thread
typedef shared_ptr<__thread_data_base> __thread_data_ptr;
class __thread_data_base
{ {
public: public:
__thread_data_base() = default; class __thread_data_base;
virtual ~__thread_data_base() = default;
virtual void _M_run() = 0; typedef shared_ptr<__thread_data_base> __thread_data_ptr;
__gthread_t _M_thread_handle; class __thread_data_base
__thread_data_ptr _M_this_ptr;
};
template<typename _Callable>
class __thread_data : public __thread_data_base
{ {
public: public:
__thread_data(_Callable&& __f) __thread_data_base() = default;
: _M_func(std::forward<_Callable>(__f)) virtual ~__thread_data_base() = default;
{ }
virtual void _M_run() = 0;
void _M_run()
{ _M_func(); } __gthread_t _M_thread_handle;
__thread_data_ptr _M_this_ptr;
private:
_Callable _M_func;
}; };
/// thread
class thread
{
public:
// types // types
class id; class id;
typedef __gthread_t native_handle_type; typedef __gthread_t native_handle_type;
...@@ -153,6 +137,21 @@ namespace std ...@@ -153,6 +137,21 @@ namespace std
private: private:
template<typename _Callable> template<typename _Callable>
class __thread_data : public __thread_data_base
{
public:
__thread_data(_Callable&& __f)
: _M_func(std::forward<_Callable>(__f))
{ }
void _M_run()
{ _M_func(); }
private:
_Callable _M_func;
};
template<typename _Callable>
__thread_data_ptr __thread_data_ptr
_M_make_thread_data(_Callable&& __f) _M_make_thread_data(_Callable&& __f)
{ {
......
...@@ -40,8 +40,9 @@ namespace std ...@@ -40,8 +40,9 @@ namespace std
{ {
void* __thread_proxy(void* __p) void* __thread_proxy(void* __p)
{ {
__thread_data_base* __t = static_cast<__thread_data_base*>(__p); thread::__thread_data_base* __t =
__thread_data_ptr __local_thread_data; static_cast<thread::__thread_data_base*>(__p);
thread::__thread_data_ptr __local_thread_data;
__local_thread_data.swap(__t->_M_this_ptr); __local_thread_data.swap(__t->_M_this_ptr);
__try __try
......
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