#futures #threadpool


An implementation of thread pools using futures

2 unstable releases

Uses old Rust 2015

0.1.0 Dec 29, 2016
0.0.1 Dec 28, 2016

#30 in #threadpool

23 downloads per month


152 lines


A library for creating futures representing work happening concurrently on a dedicated thread pool.


First, add this to your Cargo.toml:

futures = "0.1"
futures-threadpool = "0.1"

Next, add this to your crate:

extern crate futures;
extern crate futures_threadpool;

use futures_threadpool::ThreadPool;


futures-threadpool is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, and LICENSE-MIT for details.


A simple crate for executing work on a thread pool, and getting back a future.

This crate provides a simple thread pool abstraction for running work externally from the current thread that's running. An instance of Future is handed back to represent that the work may be done later, and further computations can be chained along with it as well.

extern crate futures;
extern crate futures_spawn;
extern crate futures_threadpool;

use futures::Future;
use futures_spawn::SpawnHelper;
use futures_threadpool::ThreadPool;

# fn long_running_future(a: u32) -> futures::future::BoxFuture<u32, ()> {
#     futures::future::result(Ok(a)).boxed()
# }
# fn main() {

// Create a worker thread pool with four threads
let pool = ThreadPool::new(4);

// Execute some work on the thread pool, optionally closing over data.
let a = pool.spawn(long_running_future(2));
let b = pool.spawn(long_running_future(100));

// Express some further computation once the work is completed on the thread
// pool.
let c = a.join(b).map(|(a, b)| a + b).wait().unwrap();

// Print out the result
println!("{:?}", c);
# }