tom_thread_pool 0.1.0

thread_pool
Documentation
  • Coverage
  • 14.29%
    1 out of 7 items documented0 out of 4 items with examples
  • Size
  • Source code size: 6.57 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.32 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • bythesword

use std::sync::mpsc::{self, Receiver, Sender}; use std::thread; use std::time::Duration; use thread_pool::ThreadPool;

fn main() { let (tx, rx) = mpsc::channel(); let pool = ThreadPool::new(2); let mut i: i128 = 0; let main_receiver = receiver(rx);

while true {
    let j = i.clone();
    let tx1 = tx.clone();
    let mut end = false;
    if i > 2 {
        end = true;
    }
    pool.execute(move || {
        handle_tx(j, end, tx1);
    });
    i += 1;
    thread::sleep(Duration::from_millis(1000));
    if i > 3{
        break;
    }
}
main_receiver.join().unwrap();

}