-
Notifications
You must be signed in to change notification settings - Fork 84
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
Seperating Thread creation from job execution. #7
Comments
cc @aturon |
Yes! I've been wanting to do this since I first introduced |
Yesss, I thought I was doing it wrong for wanting this. |
👍 Yes, this is exactly what I want. My use case is: I want a global thread pool to avoid paying the cost of thread creations, while dispatching jobs to it within a function to speed things up. |
Fwiw https://github.com/reem/rust-scoped-pool basically provides this interface in the now safe manner. (and the Pool is freely clonable as well). |
Yeah, I think this issue is out of date now. :) |
Right now, the
ScopedPool
API works in such a way that the handle that represents the spawned threads and the lifetime-bound RAII guard for the actual execution of jobs are one and the same type.This means its not possible to re-use the same pool of threads across different batches of job closing over disjoints lifetimes, eg:
I propose the introduction of a new type
PoolCache
whose sole purpose is to spawn N threads, and which has constructor methods for getting a RAII handle that allows temporary usage as a scoped pool:The text was updated successfully, but these errors were encountered: