All pastes #276608 Raw Edit

Untitled

public text v1 · immutable
·published 2006-12-12 15:12 UTC
rendered paste body
class CThread {
   public:
      CThread() {};
      virtual ~CThread() {};
      int Create(void *arg);
   protected:
      static void *EntryPoint(void *);
      virtual void Execute(void *arg);
      void *Arg() const {return m_arg;}
      void Arg(void *a) {m_arg = a;}
   private:
      pthread_t m_threadId;
      void *m_arg;
};


int CThread::Create(void *arg) {
   int retval;

   Arg(arg);
   retval = pthread_create(&m_threadId, NULL, CThread::EntryPoint, this);

   return retval;
}

void *CThread::EntryPoint(void *pthis) {
   CThread *pt = (CThread *)pthis;
   pt->Execute( pt->Arg() );

   return NULL;
}

void CThread::Execute(void *arg)
{

}