rayon-rs / rayon

Rayon: A data parallelism library for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docs on "spawn" don't say what exactly this function does

safinaskar opened this issue · comments

Consider spawn docs: https://docs.rs/rayon/latest/rayon/fn.spawn.html . Surprisingly, the docs don't say what exactly this function does. Let's assume that there exist not busy threads in thread pool. What will do spawn? Synchronously execute on free thread? Or start execution and immediately return? Now imagine all threads are busy. What then? Block or immediately return?

It's always non-blocking -- spawn adds your job to the queue and then returns right away. The act of queuing a job may wake up a pool thread, if any are idle, otherwise it will wait in the queue until a thread goes looking for more work.

(Doc PRs are welcome!)