Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Whats a good way of writing threaded C++ classes?

classes good threaded writing
0
Posted

Whats a good way of writing threaded C++ classes?

0

> > Ian Emmons wrote: > > > > Baard Bugge wrote: > > > > > > >How would we put the whole object into a thread? > > > > > > Been there. Done that. Let the constructor create a thread before > > > returning to the caller (another object). But beware, your OS will > > > propably start the thread by calling a function (specified by you) > > > C-style. You want this function to be a member function in your class, > > > which is ok as long as you make it static. The thread function will > > > also need the this-pointer to your newly created object. What you want > > > will look something like this (in NT): > > > > > > // Thread callback function. > > > // NOTE: Need to be written in C or be a static member function > > > // because of C style calling convention (no hidden this pointer) > > > LPTHREAD_START_ROUTINE CThread::ThreadFunc(LPVOID inputparam) > > > { > > > CThread *pseudo_this = (CThread *) inputparam; > > > … > > > } > > > > > > This function have access to all the members in th

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.