vendredi 22 mars 2019

Run class member function in separate thread

Good time of the day! I'm using Visual Studio 2015 with boost 1.66. Currently, I'm trying to run class member function in a separate thread using boost.

void ServerWorkerTh()
{

}

void StartServer() const
{
    auto f = boost::bind(&NetworkCore::ServerWorkerTh, this);
    boost::thread th(f);
}

But I'm getting

error C2440: 'argument': cannot convert from 'const NetworkCore' to 'NetworkCore &'

It seems that compiler want to receive a reference to a real object, but I'm actually giving him this. Is it possible to run class member function in a separate thread without using lambdas?

Aucun commentaire:

Enregistrer un commentaire