I have some code running in a boost thread that modifies stuff handled by the main thread which is not working and it makes sense.
On android i would have the Handler
which is a message queue that would execute my code on the main thread and i can pass whatever parameters i want to this handler.
I want to do the same with boost
so on my main thread i do the following:
boost::thread workerThread(boost::bind(&SomeClass::pollService, this));
My pollService method:
SomeClass::pollService()
{
//get some stuff from a web service
//parse the json response
//NEEDED part: call a function to be executed on the main thread and hand it some functions
}
P.S. I have looked at many io_service.post
examples and i still have no clue how to do it, and also i read an answer that said to use asio
strand
but i am also unable to understand it.
Can some one please dumb it down for me ? Please don't write something so abstract that i won't understand, I am not experienced in this. Thank you