flow.async: In Concurrent_task_loop hierarchy, ability to increase (maybe decrease) thread pool size. #63
Labels
enhancement
New feature or request
from-akamai-pre-open
Issue origin is Akamai, before opening source
Pre-open-source discussion:
colleague> It appears boost::asio's iocontext allows threads to get added on the fly, but there could be races in Flow if another thread called Concurrent_task_loop::stop() while Concurrent_task_loop was in the process of adding new threads. It seems this could be solved with a mutex that is only used for start(), stop(), and any new methods that add to the thread pool.
For adding to the pool, using Cross_thread_task_loop as an example. Cross_thread_task_loop::m_n_threads_or_zero would need to increment, Cross_thread_task_loop::m_qing_threads's vector would grow with a new Task_qing_thread instance getting added to it.
Do we need to be able to shrink the thread pool size as well?
colleague 2> Shrinking pool is not needed.
(@ygoldfeld thought: Yeah but still though....)
@ygoldfeld> (Yes, of course an io_context allows threads to be added on the fly. You just call .run() from another thread, and that's it.)
We can probably just kill all the threads and start new ones. Then it's really simple. It can even just be added to start() or something (stop() kills them, start() starts them again, n-threads arg added or soemthing). The io_context stays around and any queued tasks will just keep being queued in the meantime.
Or not. I'll have to think about it all. Segregated_thread_task_loop also needs to be considered (not just Cross_...).
The above is from 2 minutes of thinking about it.
The text was updated successfully, but these errors were encountered: