Crate tokio_rayon

Source
Expand description

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(|| {
  do_some_crypto_stuff()
}).await;

assert_eq!(nft, ExpensiveNft);

Re-exports§

Structs§

  • Async handle for a blocking task running in a Rayon thread pool.

Traits§

Functions§