You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My code needs to be able to run both sequentially and in parallel. Currently I have to implement separate sequential and parallel branches like this:
let converted = if parallelize {
templates
.par_iter().map(|&t| TemplateEngine::instance().convert(t)).collect()}else{
templates
.iter().map(|&t| TemplateEngine::instance().convert(t)).collect()};
I can let the calling code specify custom ThreadPool (or even better install it around the call), but this at best allows reducing thread count to one. I need to be able to run the code in current thread in case there's thread-local data that needs to be accessed. Having a way to locally disable parallelization would also help with #591.
Ideally, I would like my code to be either sequential by default or using global thread pool by default and let callers override this by installing their own thread pool or disabling parallelization completely.
There's rayon-cond that lets me avoid the duplication, but I still have to expose parallelization flag in the API, which is inconsistent with having ThreadPool specified via thread-local install.
The text was updated successfully, but these errors were encountered:
My code needs to be able to run both sequentially and in parallel. Currently I have to implement separate sequential and parallel branches like this:
I can let the calling code specify custom
ThreadPool
(or even better install it around the call), but this at best allows reducing thread count to one. I need to be able to run the code in current thread in case there's thread-local data that needs to be accessed. Having a way to locally disable parallelization would also help with #591.Ideally, I would like my code to be either sequential by default or using global thread pool by default and let callers override this by installing their own thread pool or disabling parallelization completely.
There's rayon-cond that lets me avoid the duplication, but I still have to expose parallelization flag in the API, which is inconsistent with having
ThreadPool
specified via thread-local install.The text was updated successfully, but these errors were encountered: