I have a multicore processor (for instance, 8 cores) and I want read a lot of files by function int read_file(...) and do it using all cores effectively. Also, after executing read_file the returned value should be placed in some place (may be in vector or queue). I'm thinking about using async (from С++11) and future (for getting result from read_file) with launch policy launch::async in a for loop over all files. But it creates a lot of threads during the execution and reading some files can be failed. Maybe I should use some guard on an amount of threads which are created during this execution?
jeudi 3 novembre 2016
What is the best way to read a lot of files simultaneously in C++?
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire