27void lauchParallelThread(
const std::vector<T> & listInputPTabModelFile,
long unsigned int nbThread, _Callable&& __f, _Args&&... __args){
28 if(nbThread == 0lu){
return;}
30 __f(listInputPTabModelFile, __args...);
33 std::vector<std::vector<T> > listInputFilePerThread;
34 phoenix_vector_split(listInputFilePerThread, listInputPTabModelFile, nbThread);
35 nbThread = listInputFilePerThread.size();
36 std::vector<std::thread> tabThread;
37 tabThread.resize(nbThread);
38 for(
long unsigned int i(0lu); i < nbThread; ++i){
39 tabThread[i] = std::thread(__f, listInputFilePerThread[i], __args...);
41 for(
long unsigned int i(0lu); i < nbThread; ++i){
55void lauchParallelThread(std::vector<T> & listInputPTabModelFile,
long unsigned int nbThread, _Callable&& __f, _Args&&... __args){
56 if(nbThread == 0lu){
return;}
58 __f(listInputPTabModelFile, __args...);
61 std::vector<std::vector<T> > listInputFilePerThread;
62 phoenix_vector_split(listInputFilePerThread, listInputPTabModelFile, nbThread);
63 nbThread = listInputFilePerThread.size();
64 std::vector<std::thread> tabThread;
65 tabThread.resize(nbThread);
66 for(
long unsigned int i(0lu); i < nbThread; ++i){
67 tabThread[i] = std::thread(__f, std::ref(listInputFilePerThread[i]), __args...);
69 for(
long unsigned int i(0lu); i < nbThread; ++i){
88 const PPath & baseOutputName,
const PPath & fileSuffix,
89 long unsigned int nbThread, _Callable&& __f, _Args&&... __args)
91 if(nbThread == 0lu){
return true;}
94 fs.open(baseOutputName + fileSuffix);
96 __f(fs, listInputPTabModelFile, __args...);
100 std::cerr <<
"lauchParallelThreadLog : cannot open file '"<<baseOutputName << fileSuffix<<
"'" << std::endl;
104 std::vector<std::vector<PPath> > listInputFilePerThread;
105 phoenix_vector_split(listInputFilePerThread, listInputPTabModelFile, nbThread);
106 nbThread = listInputFilePerThread.size();
108 std::vector<std::ofstream> vecFs;
109 vecFs.resize(nbThread);
110 std::vector<std::thread> tabThread;
111 tabThread.resize(nbThread);
112 for(
long unsigned int i(0lu); i < nbThread; ++i){
113 std::stringstream fileName;
114 fileName << baseOutputName <<
"_"<< i << fileSuffix;
115 std::ofstream & fs = vecFs[i];
116 fs.open(fileName.str());
118 tabThread[i] = std::thread(__f, std::ref(fs), listInputFilePerThread[i], __args...);
120 std::cerr <<
"lauchParallelThreadLog : thread("<<i<<
") cannot open file '"<<fileName.str()<<
"'" << std::endl;
124 for(
long unsigned int i(0lu); i < nbThread; ++i){
125 if(vecFs[i].is_open()){
146 const PPath & logFile,
147 long unsigned int nbThread, _Callable&& __f, _Args&&... __args)
149 PString extention(logFile.getExtension()), baseLogFileName(logFile.eraseExtension());
150 if(extention !=
""){extention =
"." + extention;}
151 return lauchParallelThreadLog(listInputPTabModelFile, baseLogFileName, extention, nbThread, __f, __args...);
168 long unsigned int nbThread, _Callable&& __f, _Args&&... __args)
170 if(nbThread == 0lu){
return true;}
173 fs.open(baseOutputName + fileSuffix);
179 std::cerr <<
"lauchParallelThreadLog : cannot open file '"<<baseOutputName << fileSuffix<<
"'" << std::endl;
184 std::vector<std::ofstream> vecFs;
185 vecFs.resize(nbThread);
186 std::vector<std::thread> tabThread;
187 tabThread.resize(nbThread);
188 for(
long unsigned int i(0lu); i < nbThread; ++i){
189 std::stringstream fileName;
190 fileName << baseOutputName <<
"_"<< i << fileSuffix;
191 std::ofstream & fs = vecFs[i];
192 fs.open(fileName.str());
194 tabThread[i] = std::thread(__f, std::ref(fs), __args...);
196 std::cerr <<
"lauchParallelThreadLog : thread("<<i<<
") cannot open file '"<<fileName.str()<<
"'" << std::endl;
200 for(
long unsigned int i(0lu); i < nbThread; ++i){
201 if(vecFs[i].is_open()){
221 long unsigned int nbThread, _Callable&& __f, _Args&&... __args)
223 PString extention(logFile.getExtension()), baseLogFileName(logFile.eraseExtension());
224 if(extention !=
""){extention =
"." + extention;}
void lauchParallelThread(const std::vector< T > &listInputPTabModelFile, long unsigned int nbThread, _Callable &&__f, _Args &&... __args)
Lauch the callable function __f on nbThread threads with __args to be passed to each thread.
bool lauchParallelThreadLog(const std::vector< PPath > &listInputPTabModelFile, const PPath &baseOutputName, const PPath &fileSuffix, long unsigned int nbThread, _Callable &&__f, _Args &&... __args)
Lauch the callable function __f on nbThread threads with __args to be passed to each thread.