4

Is there anything I need to watch out for when using tokio::task::spawn_blocking? I couldn't find much on the thread pool used to run these tasks. Is this thread pool pre-created? Can it grow unbounded in size?

carols10cents
  • 6,943
  • 7
  • 39
  • 56
rusty
  • 929
  • 1
  • 5
  • 10
  • You pick the thread pool numbers when you [create the runtime](https://docs.rs/tokio/0.2.11/tokio/runtime/struct.Builder.html#method.threaded_scheduler) (sometimes via the macro [`tokio::main`](https://docs.rs/tokio/0.2.11/tokio/attr.main.html)). – Shepmaster Feb 17 '20 at 20:23
  • 3
    Sorry if I was not clear. Doc for spawn_blocking says: "A closure that is run through this method will instead be run on a dedicated thread pool for such blocking tasks without holding up the main futures executor." It is not clear if this "dedicated thread pool" is the one backing the tokio run time, or is it a different thread pool? Other part I missed earlier: I read somewhere that explicit calls to spawn_blocking() are not needed anymore, as this happens internally for long running tasks. Is this correct? – rusty Feb 17 '20 at 20:44

0 Answers0