次のようなマップを返す関数があるとします。
std::map<std::string,std::string> functionname(string abc123)
ブーストスレッドを使用して、別のスレッドの同じ関数に別の文字列を渡すにはどうすればよいですか??(返される値は別の変数に格納されます)
次のようなマップを返す関数があるとします。
std::map<std::string,std::string> functionname(string abc123)
ブーストスレッドを使用して、別のスレッドの同じ関数に別の文字列を渡すにはどうすればよいですか??(返される値は別の変数に格納されます)
int main()
{
string param1 = ...;
string param2 = ...;
typedef std::map<std::string,std::string> RetT;
boost::future<RetT> f1 = boost::async(boost::launch::async,
boost::bind(functionname, param1));
boost::future<RetT> f2 = boost::async(boost::launch::async,
boost::bind(functionname, param2));
// here they run....
RetT r1 = f1.get(); // waits for f1
RetT r2 = f2.get(); // waits for f2
// Here we have the results in r1 and r2
}