Crate lagoon[][src]

Expand description

Lagoon is a thread pool crate that aims to address many of the problems with existing thread pool crates.


  • Scoped jobs: Safely spawn jobs that have access to their parent scope!
  • Job handles: Receive the result of a job when it finishes, or wait on it to finish!
  • Global pool: A pay-for-what-you-use global thread pool that avoids dependencies fighting over resources!
  • Customise thread attributes: Specify thread name, stack size, etc.
let pool = lagoon::ThreadPool::default();

// Spawn some jobs that notify us when they're finished
let jobs = (0..10)
    .map(|i| pool.run_recv(move || {
        println!("Hello! i = {}", i);

// Wait for all jobs to finish
for job in jobs {


A handle that refers to a job that notifies on completion. It may be created with ThreadPool::run_recv.

A scope within which jobs that refer to their parent scope may safely be spawned.

A pool of threads that may be used to execute jobs.

A type used to configure a ThreadPool prior to its creation.


An error that may be produced when creating a ThreadPool.


Attempt to determine the available concurrency of the host system.