#ifdef HAVE_CONFIG_H #include #endif #include #include #include #include using namespace std; namespace ldap_proxy { class Thread { public: Thread(); virtual ~Thread(); void start(); void wait(); virtual void run() {}; private: pthread_t thread; }; } extern "C" { static void* do_call_run(void* arg) { if (arg) { ldap_proxy::Thread* t = (ldap_proxy::Thread*)arg; t->run(); } return 0; } } namespace ldap_proxy { Thread::Thread() { // empty } Thread::~Thread() { pthread_join(thread,0); } void Thread::start() { pthread_create(&thread,0,do_call_run,this); } void Thread::wait() { pthread_join(thread,0); } }