32 _size(0), _exit(false)
34 _pool.reserve(threads);
36 #ifdef JEVOIS_PLATFORM
56 for(
unsigned int i = 0; i < threads; ++i)
58 _pool.emplace_back([
this]{
59 fu2::unique_function<void()> task;
64 std::unique_lock<std::mutex> lock(_mtx);
65 _new_task.wait(lock, [
this]{
return _size || _exit; });
72 while (_tasks.try_dequeue(task)) { _size--; task(); }
76 if (_tasks.try_dequeue(task))
85 #ifdef JEVOIS_PLATFORM
87 int rc = pthread_setaffinity_np(_pool.back().native_handle(),
sizeof(cpu_set_t), &cpuset);
88 if (rc)
LERROR(
"Error calling pthread_setaffinity_np: " << rc);
93 #ifdef JEVOIS_PLATFORM
94 auto fut =
execute([threads,little](){
95 LINFO(
"Initialized with " << threads << (little ?
" A53 threads." :
" A73 threads.")); });
98 LINFO(
"Initialized with " << threads <<
" threads."); });
107 std::scoped_lock<std::mutex> lock(_mtx);
111 _new_task.notify_all();
112 for (
auto & thread: _pool) thread.join();