-
Notifications
You must be signed in to change notification settings - Fork 501
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
Add a mean to get the current threadpool #841
base: main
Are you sure you want to change the base?
Conversation
a6b333c
to
95b44e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hesitate to expose ThreadPool
like this because it leaves us with no clear owner of the pool. The Registry
is shared because each thread in that pool also holds a handle, but it would be nice if ThreadPool
remains a bit stronger, as the Drop
semantics imply by calling registry.terminate()
. There have also been requests to support a synchronized shutdown, which should naturally consume self
by value, but that semantic doesn't work as well if ThreadPool
is a shared handle.
Can you say more about what you want to do with this? Most of the free functions already work naturally with the current pool, whether that's global or something custom, so I wonder why you actually need the ThreadPool
itself.
It is useful when you want to share the same threadpool across threads outside the threadpool.
95b44e4
to
9df5ba4
Compare
So far I used it to |
Maybe we can return some kind of opaque id |
What would you be able to do with an opaque id? It seems to me what's wanted is just to run things on the pool, not share ownership, so maybe we need some kind of |
@cuviper print it out so you can make sure which threadpool is which |
It is also nice so I do not have the annoying pattern of
I currently have in |
Doesn't |
My usecase is to not have to special case between a custom pool and the global pool. Some users would enjoy setting the threadpool according to certain constraint, others would just use the global threadpool they already set for their needs or share a threadpool otherwise created. |
It is useful when you want to share the same threadpool across
threads outside the threadpool.