Ensuring foreign code gets run on a local rayon pool

Hey all,

So I have multiple rayon pools so that one task that may have parallelisation does not interfere with another task's parallelisation.

And I put a rayon::install at the base of this particular code so that later down in the codebase I don't have to concern myself with passing the pool around, but also calling foregein crates will do their work on my desired pool.

In fact, I use a current_thread tokio runtime so that I can still use async functions, and the only gotcha is that i can not use spawn_blocking because tokio will put that work on a separate thread, and if it then does work on rayon, it will get executed on the global threadpool, and concurrent tasks will use that same pool. - Not what I want. This is also no a problem because each task has it's own tokio runtime so you are free to block it.

And there's a clippy lint that i can configure to deny disallowed methods.

Now however, i realised, If i call a library crate, and it spawns a thread which then uses rayon, it will not use the pool i want it to, and I don't think there's anything I can do about it?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.