Quote:Original post by thedustbustr
Is there a better way than this:spawn a thread(){ ... std::vector<void*> *params = new std::vector<void*>; params->push_back(object); params->push_back(name); Thread *t = new Thread(EntryPoint, params);}
and put the thread pointer in some kind of smart pointer to lose the memory leak.
fwiw this implementation crashes on some computers but not all with apparent memory corruption.
I love it when people make things so complicated. there's a simple way to do this.
If you know what you are passing to the thread,and the thread knows what he's getting, just do this:
struct{ tObject object; tName name;} tParams;{ tParams *pParams = new tParams; pParams->object = Object; pParams->name = Name; Thread *t = new Thread(EntryPoint, (void *)pParams);}void EntryPoint(void *pParams){ Object object; Name name; tParams *pTemp; pTemp = (tParams *)pParams; object = pParams->object; name = pParams->name; delete pTemp;}
Oh NOES, IT'S NOT SAFE!!!
Or you could load up a few megs of library code, and add more complexity to your code to do the same thing.
[Edited by - BeerNutts on June 17, 2008 4:45:38 PM]