//////////////////////////////////////////////////////////////////////// // class CThread // // $Log: thread.h,v $ // Revision 1.2 1997/07/23 18:26:43 nettleto // Added function to set stacksize. // // Revision 1.1 1997/06/13 18:16:45 nettleto // Initial revision // // #ifndef THREAD_H #define THREAD_H // This class offers the basic functionality of a POSIX Thread. To define // an application program thread, you should derive a class from the class // CThread and override the member function 'Body' with the application // code. // #include class CThread { protected: pthread_t t; public: CThread () { pthread_create (&t, NULL, Start, (void *) this); } CThread (size_t stacksize) { pthread_attr_t attr; pthread_attr_init (&attr); pthread_attr_setstacksize (&attr, stacksize); pthread_create (&t, &attr, Start, (void *) this); } int Join () { int status; pthread_join (t, (void **)(&status)); return status; } protected: virtual void Body () {}; friend void *Start (void *); }; #endif // not THREAD_H