Closed yanzixiang closed 1 year ago
Thanks for the feature request! One of the guiding design principles of this package is that it only uses the C++17 standard library, and does not rely on any 3rd-party and/or platform-dependent features. Unfortunately, integration with the 3rd-party package cpuaff will go against this principle, and therefore will not be implemented. However, you are welcome to start your own fork with cpuaff integration.
Thanks for the feature request! One of the guiding design principles of this package is that it only uses the C++17 standard library, and does not rely on any 3rd-party and/or platform-dependent features. Unfortunately, integration with the 3rd-party package cpuaff will go against this principle, and therefore will not be implemented. However, you are welcome to start your own fork with cpuaff integration.
there is no need to rely on any 3rd-party and/or platform-dependent features,
this feature can be done by add a callback
/**
* @brief A worker function to be assigned to each thread in the pool. Waits until it is notified by push_task() that a task is available, and then retrieves the task from the queue and executes it. Once the task finishes, the worker notifies wait_for_tasks() in case it is waiting.
*/
void worker()
{
callback_to_config_the_thread()......
while (running)
{
std::function<void()> task;
std::unique_lock<std::mutex> tasks_lock(tasks_mutex);
task_available_cv.wait(tasks_lock, [&] { return !tasks.empty() || !running; });
if (running && !paused)
{
task = std::move(tasks.front());
tasks.pop();
tasks_lock.unlock();
task();
--tasks_total;
if (waiting)
task_done_cv.notify_one();
}
}
}
What you're asking for seems to be similar to #105, which is planned to be implemented in the next release.
cpuaff integration the lib make all the threads private, Is it possible to give the user the opportunity to make some modify to the threads ? i want to make Multiple Thread Pools, as if one pool bind to core 1,2, and another pool bind to core 3,4, so that i can push task to the binded core
Code example
Additional information
http://dcdillon.github.io/cpuaff/
https://github.com/bshoshany/thread-pool/issues/37