tokio-thread-pool 1.0.0

A small wrapper around the tokio runtime supporting max concurrency
Documentation
  • Coverage
  • 66.67%
    4 out of 6 items documented4 out of 4 items with examples
  • Size
  • Source code size: 7.38 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.41 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • alexfigliolia

Tokio Thread Pool

A small wrapper around the tokio runtime supporting multithreading with max concurrency limits

Installation

cargo add tokio-thread-pool

API

use tokio_thread_pool::ThreadPool;

let my_pool = ThreadPool::new(
  None, // optional max task concurrency (Option<usize>),
  None, // optional max number of threads defaulting to the number of CPU cores on the system (Option<usize>),
  None, // an optional tokio runtime that you provide with your own custom settings (Option<tokio::Runtime>)
);

// Spawn async tasks
let handle = my_pool.spawn(async move || {}); // return any value
// Spawn sync tasks
let handle = my_pool.spawn_blocking(move || {}); // return any value

// Get result
let result = handle.await;