#ifndef THREAD_PTR_H__ #define THREAD_PTR_H__ #include namespace tiny_http_server { class thread { private: pthread_t hnd_; public: static void* wrapper(void *ptr) { thread *p = static_cast(ptr); p->run(); return 0; } virtual void run() {} void start() { pthread_create(&hnd_, 0, &thread::wrapper, static_cast(this)); } void join() { pthread_join(hnd_, 0); } virtual ~thread() {} }; } #endif