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?
You can use pass by reference to get value from thread
#include <tbb/tbb.h>
void GetSomething(int *result)
{
result= // do something
}
// ...
int result;
tbb::tbb_thread(GetSomething, &result);
tbb.join();
//use result as you like