Creating A Thread W/ PThreads within an Object
I have a program that's been working fine, but now I'm changing it to use objects (I don't want to go into reasoning, but even if I don't change it, I want to know how to do this).
I have been using one routine, which will be public, to call another and start the thread:
Code:
void * HDListen::listenthread(void *generic_pointer) {//protected
readinfile();
ioport.closeport();
return NULL;
}
void HDListen::listentoradio() {//public
pthread_create(&listenThread, NULL, listenthread, NULL);
return;
}
So far it's worked fine, but now that I'm putting these functions into an object, I'm using prototypes in the header and have this:
Code:
class HDListen {
//Lots of variables that don't relate to this question...
pthread_t listenThread;
LinuxPort ioport;
public:
HDListen(LinuxPort);
void listentoradio();
protected:
void *listenthread(void*);
};
It seems no matte how I tweak the prototype of listenthread(), I can't get it right so it's accepted in the header file as okay and so it matches what's in the .cpp file. Why isn't it working and what do I need to change.
And, while I'm on this issue, is it possible to make this work with passing a value to this routine or returning one -- or just not having it even return NULL?
Thanks!