#thread-pool #async #async-task #blocking

async-cpupool

A simple async threadpool for CPU-bound tasks

4 releases

0.2.2 Apr 15, 2024
0.2.1 Feb 12, 2024
0.2.0 Jan 7, 2024
0.1.0 Nov 26, 2023

#225 in Concurrency

Download history 15/week @ 2024-01-13 6/week @ 2024-01-20 89/week @ 2024-01-27 14/week @ 2024-02-03 40/week @ 2024-02-10 61/week @ 2024-02-17 23/week @ 2024-02-24 11/week @ 2024-03-02 19/week @ 2024-03-09 17/week @ 2024-03-16 25/week @ 2024-03-30 14/week @ 2024-04-06 165/week @ 2024-04-13 21/week @ 2024-04-20 7/week @ 2024-04-27

208 downloads per month
Used in ap-relay

GPL-3.0 license

35KB
896 lines

Async CPUPool

A simple async threadpool for CPU-bound tasks

Usage

Add to your Cargo.toml

$ cargo add async-cpupool

Use in your application

fn complex_computation() {}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    smol::block_on(async {
        let pool = async_cpupool::CpuPool::new();

        pool.spawn(move || {
            complex_computation();
        }).await?;

        pool.close().await;

        Ok(())
    })
}

Contributing

Feel free to open issues for anything you find an issue with. Please note that any contributed code will be licensed under the GPLv3.

License

Copyright © 2023 asonix

Async CPUPool is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Async CPUPool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This file is part of Async CPUPool.

You should have received a copy of the GNU General Public License along with Async CPUPool. If not, see http://www.gnu.org/licenses/.

Dependencies

~1.1–1.6MB
~23K SLoC