Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

#[cfg(test)]mod tests {use std::{thread::sleep, time::Duration};usesuper::*;#[test]fntest_workers(){structTaskImpl{id:u32,one_shot_rx:Receiver<i32>,one_shot_tx:Sender<i32>,}implTaskforTaskImpl{fnexecute(&self){println!("Task {} is running",self.id);self.one_shot_tx.send(100).unwrap();println!("Task {} is done",self.id);}fnid(&self) -> u32{self.id}}implTaskImpl{fnget_result(&self) -> i32{self.one_shot_rx.recv().unwrap()}}letmut workers = Workers::new(4);
workers.run();for i in0..10{let(tx, rx) = std::sync::mpsc::channel::<i32>();let task = TaskImpl{id: i,one_shot_rx: rx,one_shot_tx: tx,};
workers.add_task(Box::new(task));}sleep(Duration::from_secs(5));}}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages