bshoshany/thread-pool

[REQ] Run function on all threads

lgs-baada opened this issue · 1 comments

Describe the new feature

Run a function on all threads when creating (or changing) the thread pool.

Code example

BS::thread_pool pool([] { nice(1); });

Or:

BS::thread_pool pool(12, [] { nice(1); });

Or:

BS::thread_pool pool([] (auto id) {
    const auto name = std::format("worker{}", id);
    pthread_setname_np(pthread_self(), name.c_str());
});

Additional information

This feature can be used to change settings of the threads (priority, name, etc.).

Thank you for this feature request! This has already been requested in #105, and is set to be incorporated in the next release (which may be in a couple of months).