multithreading - C++ - Optimal number of threads for processing string -


i have std::string of length n , want insert substrings of length k std::set container, using threads. how many std::thread or pthread_t objects should use?

consider n = 500,000 , k = 3.

use threadpool.

it pretty simple use, you'll have include "threadpool.h" , can set maximum number of threads based on number of cores available. code should contain following snipet.

 int max_threads = std::thread::hardware_concurrency();  threadpool pool(max_threads);  auto result = pool.enqueue(func,params);  

here func function called, params parameters , value returned stored in result.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -