Crates.io | ordq |
lib.rs | ordq |
version | 0.2.0 |
source | src |
created_at | 2024-04-29 14:48:47.30816 |
updated_at | 2024-04-30 05:27:26.935371 |
description | Order keeping job processing queue |
homepage | https://github.com/drmingdrmer |
repository | https://github.com/drmingdrmer/ordq |
max_upload_size | |
id | 1224227 |
size | 23,004 |
Order keeping job processing queue
Example:
struct Add;
impl ordq::Work for Add {
type I = (i32, i32);
type O = i32;
fn run(&mut self, x: Self::I) -> Self::O {
x.0 + x.1
}
}
# fn test_jobq() {
let (tx, rx) = ordq::new(1024, vec![Add, Add]);
tx.send((1, 2));
tx.send((3, 4));
tx.close();
assert_eq!(rx.recv(), Some(Ok(3)));
assert_eq!(rx.recv(), Some(Ok(7)));
assert_eq!(rx.recv(), None);
assert_eq!(rx.recv(), None);
# }