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