gecko-dev/third_party/rust/tokio-threadpool
Bastien Orivel faf6cad78c Bug 1580908 - Part 10: Revendor dependencies. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D45719

--HG--
rename : third_party/rust/regex-0.2.2/src/freqs.rs => third_party/rust/aho-corasick/src/byte_frequencies.rs
rename : third_party/rust/crc/Cargo.toml => third_party/rust/blake2b_simd/Cargo.toml
rename : third_party/rust/miniz_oxide_c_api/LICENSE => third_party/rust/miniz_oxide/LICENSE
rename : third_party/rust/redox_users/tests/group => third_party/rust/redox_users/tests/etc/group
rename : third_party/rust/redox_users/tests/passwd => third_party/rust/redox_users/tests/etc/passwd
rename : third_party/rust/redox_users/tests/shadow => third_party/rust/redox_users/tests/etc/shadow
rename : third_party/rust/utf8-ranges/src/lib.rs => third_party/rust/regex-syntax/src/utf8.rs
rename : third_party/rust/crossbeam-channel/LICENSE-APACHE => third_party/rust/rust-argon2/LICENSE-APACHE
rename : third_party/rust/memchr-1.0.2/COPYING => third_party/rust/winapi-util/COPYING
rename : third_party/rust/ucd-util/Cargo.toml => third_party/rust/winapi-util/Cargo.toml
rename : third_party/rust/memchr-1.0.2/LICENSE-MIT => third_party/rust/winapi-util/LICENSE-MIT
rename : third_party/rust/memchr-1.0.2/UNLICENSE => third_party/rust/winapi-util/UNLICENSE
extra : moz-landing-system : lando
2019-09-12 21:46:32 +00:00
..
benches Bug 1580908 - Part 10: Revendor dependencies. r=froydnj 2019-09-12 21:46:32 +00:00
examples Bug 1580908 - Part 10: Revendor dependencies. r=froydnj 2019-09-12 21:46:32 +00:00
src Bug 1580908 - Part 10: Revendor dependencies. r=froydnj 2019-09-12 21:46:32 +00:00
tests Bug 1580908 - Part 10: Revendor dependencies. r=froydnj 2019-09-12 21:46:32 +00:00
.cargo-checksum.json Bug 1580908 - Part 10: Revendor dependencies. r=froydnj 2019-09-12 21:46:32 +00:00
CHANGELOG.md Bug 1580908 - Part 10: Revendor dependencies. r=froydnj 2019-09-12 21:46:32 +00:00
Cargo.toml Bug 1580908 - Part 10: Revendor dependencies. r=froydnj 2019-09-12 21:46:32 +00:00
LICENSE
README.md Bug 1580908 - Part 10: Revendor dependencies. r=froydnj 2019-09-12 21:46:32 +00:00

README.md

Tokio Thread Pool

A library for scheduling execution of futures concurrently across a pool of threads.

Documentation

Why not Rayon?

Rayon is designed to handle parallelizing single computations by breaking them into smaller chunks. The scheduling for each individual chunk doesn't matter as long as the root computation completes in a timely fashion. In other words, Rayon does not provide any guarantees of fairness with regards to how each task gets scheduled.

On the other hand, tokio-threadpool is a general purpose scheduler and attempts to schedule each task fairly. This is the ideal behavior when scheduling a set of unrelated tasks.

Why not futures-cpupool?

It's 10x slower.

Examples

extern crate tokio_threadpool;
extern crate futures;

use tokio_threadpool::ThreadPool;
use futures::{Future, lazy};
use futures::sync::oneshot;

pub fn main() {
    let pool = ThreadPool::new();
    let (tx, rx) = oneshot::channel();

    pool.spawn(lazy(|| {
        println!("Running on the pool");
        tx.send("complete").map_err(|e| println!("send error, {}", e))
    }));

    println!("Result: {:?}", rx.wait());
    pool.shutdown().wait().unwrap();
}

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tokio by you, shall be licensed as MIT, without any additional terms or conditions.