C++ Thread Class
Hi All,
I am writting a Thread class with using pthread library. I have some
problem in saving thread function type and argument type. How to make
Thread class generic ?
/* This is my global Function */
template < class FunType, class ArgType>
Thread makeThread(Funtype fun, ArgType arg)
{
Thread thr;
/* How to save Funtype and ArgType in the Thread object ?? */
return thr;
}
/* This is my thread class */
class Thread
{
void start()
{
/* pthread_create here to create a new thread */
}
};
class A
{
static void myfunA(A *ptr)
{
/* This function will run as a new thread); */
}
};
class B
{
static void myfunB(B *ptr)
{
}
}
main()
{
A *objptrA = new A();
Thread thrA = makeThread(myfunA, objptrA);
thrA.start();
B *objptrB = new B();
Thread thrB = makeThread(myfunB, objptrB);
thrB.start();
}
Thanks
Jayesh Shah.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]