I was playing around with threads to improve some code.....with no luck whatsoever..
Any way.. I tried to get the following loop running concurrently.
My try:Code:for(auto x=args.begin();x!=args.end();x++) { list l; if(is_list(*x,l)) *x = l.eval(); }
(Notice that the list is passed by value...to avoid mishaps)Code:std::vector<std::thread> threads; list temp; for(auto x=args.begin();x!=args.end();x++) if(is_list(*x,temp)) threads.push_back(std::thread([](list l,std::string& ret){ret = l.eval();},temp,*x)); for(auto t = threads.begin();t!=threads.end();t++)t->join();
But clearly something(else?) has gone wrong...
N.B: list is NOT std::list



LinkBack URL
About LinkBacks



