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
Post a Comment