A threadpool for executing blocking operations from an async context
Go to file
asonix 6d5e171e25
/ check (aarch64-unknown-linux-musl) (push) Successful in 16s Details
/ check (armv7-unknown-linux-musleabihf) (push) Successful in 13s Details
/ check (x86_64-unknown-linux-musl) (push) Successful in 13s Details
/ tests (push) Successful in 20s Details
/ clippy (push) Successful in 10s Details
Only run checks for branches
2024-02-12 13:36:16 -06:00
.forgejo/workflows Only run checks for branches 2024-02-12 13:36:16 -06:00
examples Remove expects from demo 2023-11-25 21:10:05 -06:00
src Remove thread ID from metrics 2024-02-12 13:32:52 -06:00
.gitignore Simple CPU Pool 2023-11-24 13:42:10 -06:00
Cargo.toml Bump version 2024-02-12 13:34:30 -06:00
LICENSE Add license, readme, docs, & error impls 2023-11-25 21:08:15 -06:00
README.md Update cargo.toml 2023-11-25 21:13:49 -06:00
flake.lock Simple CPU Pool 2023-11-24 13:42:10 -06:00
flake.nix Simple CPU Pool 2023-11-24 13:42:10 -06:00

README.md

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/.