I'm trying to make a thread to callback a function of the object that created the thread. But it seems it is not posible to pass "this" as a parameter. Is there a way to implement this? Thanks in advance.
Helper.cpp
void Helper::ProcessSomething(void (*callback)(void))
{
boost::this_thread::sleep(boost::posix_time::seconds(1));
callback();
}
SomeClass.cpp
void SomeClass::Start(void)
{
Helper *helper = Helper();
boost::thread t(&Helper::ProcessSomething, helper, &this->SomeCallback);
t.join();
}
void SomeClass::SomeCallback(void)
{
std::cout << "Callback called" << std::endl;
}