Crate tokio_rayon[][src]

Tokio’s spawn_blocking and block_in_place run blocking code on a potentially large number of Tokio-controlled threads. This is suitable for blocking I/O, but CPU-heavy operations are often better served by a fixed-size thread pool. The Rayon crate provides exactly this, so… Why not combine them? :)

let nft = tokio_rayon::spawn_async(|| {
  do_some_crypto_stuff()
}).await?;

assert_eq!(nft, ExpensiveNft);

Modules

prelude

Prelude module to bring in extension methods.

Traits

AsyncThreadPool

Extension trait that integrates Rayon’s ThreadPool with Tokio.

Functions

spawn_async

Asynchronous wrapper around Rayon’s spawn.

spawn_fifo_async

Asynchronous wrapper around Rayon’s spawn_fifo.