Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flow.async: In Concurrent_task_loop hierarchy, ability to increase (maybe decrease) thread pool size. #63

Open
ygoldfeld opened this issue Mar 9, 2024 · 0 comments
Labels
enhancement New feature or request from-akamai-pre-open Issue origin is Akamai, before opening source

Comments

@ygoldfeld
Copy link
Contributor

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.

@ygoldfeld ygoldfeld added enhancement New feature or request from-akamai-pre-open Issue origin is Akamai, before opening source labels Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request from-akamai-pre-open Issue origin is Akamai, before opening source
Projects
None yet
Development

No branches or pull requests

1 participant