getting a return value from a bind?

hi , i have on my code something like boost::thread thrd(boost::bind(&myioTCPLTE,TCPmsg)) function myioTCPLTE return a string value, bu i dont now how to get it to store in a different variable from the main code!! Could anyone help me? thanks -- Pedro Alonso Chaparro Valero R&D Engineer Ciudad Politecnica de la Innovación iTEAM - Mobile Communications Group Polytechnic University of Valencia C\ Camino de Vera S/N, Edificio 8G 46022 Valencia, Spain

boost::thread thrd(boost::bind(&myioTCPLTE,TCPmsg))
function myioTCPLTE return a string value, bu i dont now how to get it to store in a different variable from the main code!! Could anyone help me? thanks
Thread function runs in different thread, asynchronously, so where and when do you mean to get its return value? You can take a look at the "future" concept: http://www.boost.org/doc/libs/1_45_0/doc/html/thread/synchronization.html#th... Quoting from there: <<This is an answer to the perennial question: "how do I return a value from a thread?": package the function you wish to run as a boost::packaged_task and pass the packaged task to the thread constructor. The future retrieved from the packaged task can then be used to obtain the return value. If the function throws an exception, that is stored in the future in place of the return value.>>
participants (2)
-
Igor R
-
pedro chaparro