MCPcopy Create free account
hub / github.com/OpenMined/TenSEAL / ThreadPool

Method ThreadPool

tenseal/cpp/utils/threadpool.h:36–48  ·  view source on GitHub ↗

* Create "n_threads" workers, each with a dedicated task queue, and execute * the task as they arrive in the queues. **/

Source from the content-addressed store, hash-verified

34 * the task as they arrive in the queues.
35 **/
36 ThreadPool(unsigned int n_threads = get_concurrency())
37 : m_queues(n_threads), m_count(n_threads) {
38 assert(n_threads != 0);
39 auto worker = [&](unsigned int i) {
40 while (true) {
41 Proc f;
42 if (!m_queues[i].pop(f)) break;
43 f();
44 }
45 };
46 for (unsigned int i = 0; i < n_threads; ++i)
47 m_workers.emplace_back(worker, i);
48 }
49
50 ~ThreadPool() noexcept {
51 for (auto& queue : m_queues) queue.done();

Callers

nothing calls this directly

Calls 2

get_concurrencyFunction · 0.85
popMethod · 0.80

Tested by

no test coverage detected