Caffe2 - C++ API
A deep learning, cross platform ML framework
pthreadpool_impl.cc
1 #include "caffe2/utils/threadpool/pthreadpool.h"
2 #include "caffe2/utils/threadpool/pthreadpool_impl.h"
3 #include "caffe2/utils/threadpool/ThreadPool.h"
4 
5 
6 //
7 // External API
8 //
9 
10 void pthreadpool_compute_1d(struct pthreadpool* threadpool,
11  pthreadpool_function_1d_t function,
12  void* argument,
13  size_t range) {
14  threadpool->pool_->run(
15  [function, argument](int threadId, size_t workId) {
16  function(argument, workId);
17  },
18  range);
19 }
20 
21 size_t pthreadpool_get_threads_count(struct pthreadpool* threadpool) {
22  return threadpool->pool_->getNumThreads();
23 }