In the code:
#include <tbb/tbb.h>
int GetSomething()
{
int something;
// do something
return something;
}
// ...
tbb::tbb_thread(GetSomething, NULL);
// ...
Here GetSomething() was called in another thread via its pointer. But can we get return value from GetSomething()? How?
If you are bound C++03 and tbb you have to use Outputarguments, which means that you have to rewrite your function.
e.g.:
or with
boost::refyou can do this:If you can use C++11 the task is simplified by using
futures:e.g.:
Here you don’t have to rewrite anything.