|
Boost Users : |
Subject: Re: [Boost-users] getting a return value from a bind?
From: Igor R (boost.lists_at_[hidden])
Date: 2011-01-31 07:33:32
> 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#thread.synchronization.futures
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.>>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net