| 31 | | |
| 32 | | template <typename IMPL> |
| 33 | | class pthread_thread { |
| 34 | | public: |
| 35 | | pthread_thread(IMPL* pimpl); |
| 36 | | virtual ~pthread_thread(); |
| 37 | | private: |
| 38 | | pthread_t m_thread; |
| 39 | | static void* trampoline(void* obj); |
| 40 | | private: |
| 41 | | pthread_thread(); |
| 42 | | pthread_thread(const pthread_thread&); |
| 43 | | }; |
| 44 | | |
| 45 | | template <typename IMPL> |
| 46 | | pthread_thread<IMPL>::pthread_thread(IMPL* pimpl) |
| 47 | | { |
| 48 | | pthread_create(&m_thread, NULL, |
| 49 | | &pthread_thread<IMPL>::trampoline, |
| 50 | | reinterpret_cast<void*>(pimpl)); |
| 51 | | } |
| 52 | | |
| 53 | | template <typename IMPL> |
| 54 | | pthread_thread<IMPL>::~pthread_thread() {} // FIXME |
| 55 | | |
| 56 | | template <typename IMPL> |
| 57 | | void* pthread_thread<IMPL>::trampoline(void* obj) |
| 58 | | { |
| 59 | | // FIXME exception |
| 60 | | reinterpret_cast<IMPL*>(obj)->operator()(); |
| 61 | | return NULL; |
| 62 | | } |