I've been using _beginthread within my (windows) C++ class to create threads. As I have learned, to use _beginthread and pass a member function within a class, there is a rather obtuse wrapping protocol that has to be followed, for example:
class MyClass
{
public:
void fun_1()
{
_beginthread(&MyClass::fun_2_wrapper, 0, static_cast<void*>(this));
}
private:
void fun_2()
{
printf("hello");
}
static void __cdecl fun_2_wrapper(void* o)
{
static_cast<MyClass*>(o)->fun_2();
}
};
I have been having trouble translating this model to one that accepts arguments for my thread function. For instance, if I wanted my thread function to instead be:
void fun_2(int a)
How would I properly adapt my function calls? (Note, I am trying to accomplish this without boost::thread or similar libraries for project consistency)