3 ms·
One approach I’ve used in the past is to offer an API which takes threads or a worker pool as a parameter, and a separate API which does that for you and calls
by binary132 3y ago
One approach I’ve used in the past is to offer an API which takes threads or a worker pool as a parameter, and a separate API which does that for you and calls the first one.
Then in your Python wrapper you can use the wrapper, but your users who care can provide the pool they’ve already created.
Bonus points if it’s an interface or trait that the user can adapt their own scheduler to, if they don’t use rayon. But, I can see how that could be tricky if the design of your library is tightly coupled with the threading solution.
One way to frame it is that thread creation is a significant side effect.