c++ - pass arguments to function in a boost::thread -
this first time using boost thread function , prior have little knowledge of working multiple threads. attempting run second instance of function alongside initial call can pass 2 different variables same function, i'm hoping speeds program up. code have know keep getting c2784 error says
't *boost::get_pointer(const boost::scoped_ptr<t> &)' : not deduce template argument 'const boost::scoped_ptr<t> &' 'const std::string'
here's snippet of code deals thread creation
string firstpart = rectext.substr(1,(subpart1-1)); string secondpart = rectext.substr(subpart1,subpart1); boost::thread firstthread; boost::thread secondthread; firstthread = boost::thread(&conversion::conversion,firstpart); secondthread = boost::thread(&conversion::conversion,secondpart); firstthread.join(); secondthread.join();
edit
void conversion::conversion(string _part) { int value_part = 1; int valueshort = 0; int value = checkvalue; if(value == value_part) { // stuff } }
member functions take implicit first parameter of type (cv qualified) t*
, t
class member function. need pass pointer conversion
instance, example,
conversion c; firstthread = boost::thread(&conversion::conversion, &c, firstpart);
Comments
Post a Comment