multithreading - c++ Boost Multithread Running Slow when two threads read file and tokenize the CSV File -


i have 2 functions, used work me, did changes in codes don't know happened. when executed functions multi-threads, cpu 10-30%, , slow. readfile line parse csv line using boost token.

        boost::thread offlineul(&avatti::avacollectttiadvance::ueandcellparamparseul,c,tracefilenameul.c_str(),numoflines,ghostfilter,"","/",offlinemode,openexcelauto);         boost::thread offlinedl(&avatti::avacollectttiadvance::ueandcellparamparsedl,c,tracefilenamedl.c_str(), numoflines,"","/",offlinemode,openexcelauto);         offlinedl.join();         offlineul.join();       int avacollectttiadvance::ueandcellparamparsedl(const char *inname, int numofrecords, const char *userdir, const char* currentdir, int offlinemode, int openexcelauto)     {        typedef boost::tokenizer <boost::escaped_list_separator<char> > my_tokenizer;        vector <string> mystr;         std::ifstream infile(ttiasciitraceoutputuserdir.str(),std::ios::in);       while (getline(infile, line)  && linecount <= numofrecords)        (my_tokenizer::iterator it(tok.begin()), end(tok.end()); != end; ++it)       {          mystr.push_back(*it);       }       ....................       .................... 

can please help? running out ideas. thanks.

if have shared resources amongst threads, such vector mystr need use thread synchronization mechanisms access these resources, otherwise vector corrupted.

this true variable accessed multiple threads @ once, if being written @ least 1 thread.

i cannot problem not providing enough data, cannot make out code variables local, , one's aren't , variables used 1 or multiple threads.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -