multithreading

Crates.iomultithreading
lib.rsmultithreading
version0.3.0
sourcesrc
created_at2024-03-08 18:50:37.332982
updated_at2024-09-25 09:05:30.317319
descriptionA simple multithreading library in Rust
homepage
repositoryhttps://github.com/LOSEARDES77/multithreading-rs
max_upload_size
id1167211
size7,222
LOSEARDES77 (LOSEARDES77)

documentation

README

Multithreading Library Written In Rust


A simple multithreading library written in rust.

Usage

use multithreading::ThreadPool;

fn main() {
    let pool = ThreadPool::new(<number_of_threads_to_use>);
    for i in 0..10 {
        pool.execute(move || {
            // Do something
            println!("Task {}", i);
        });
    }
}

if you want to use all available threads, you can use the crate num_cpus to get the number of available threads.

use multithreading::ThreadPool;
use num_cpus;

fn main() {
    let pool = ThreadPool::new(num_cpus::get());
    for i in 0..10 {
        pool.execute(move || {
            // Do something
            println!("Task {}", i);
        });
    }
}
Commit count: 17

cargo fmt