#ifndef WRAPPER_H_ #define WRAPPER_H_ // ---- Class for "wrapper" program for calling object's run() ------- // The point of this class is to have a way of passing an object's // run() member function to pthread_create. // Example use: // If threadObj is a class that has // typedef threadObj * ptr // and a member function // void run(void) // and you have declarations // thread_t theThread; // threadObj theThreadObj(....); // you can call pthread_create thus: // pthread_create(&theThread, NULL, // threadWrapper::run, // (void *) &theThreadObj); // See other sample programs for more examples of use. template class threadWrapper { public: // Static (i.e., no current object needed) function to invoke // the run() method of object theThreadObj. // Intended to be passed to pthread_create along with a pointer // to theThreadObj; pthread_create then invokes the code // below, with threadArg pointing to theThreadObj. static void * run(void * threadArg) { ThreadObjPtrType objPtr = (ThreadObjPtrType) threadArg; objPtr->run(); return NULL; } }; #endif // WRAPPER_H_