2 unstable releases

0.2.0 Apr 30, 2024
0.1.0 Apr 29, 2024

#745 in Algorithms

Download history 1681/week @ 2024-07-25 1788/week @ 2024-08-01 1374/week @ 2024-08-08 1569/week @ 2024-08-15 847/week @ 2024-08-22 1169/week @ 2024-08-29 1123/week @ 2024-09-05 857/week @ 2024-09-12 1145/week @ 2024-09-19 570/week @ 2024-09-26 431/week @ 2024-10-03 1043/week @ 2024-10-10 897/week @ 2024-10-17 1165/week @ 2024-10-24 1107/week @ 2024-10-31 1120/week @ 2024-11-07

4,508 downloads per month

MIT/Apache

10KB
185 lines

ordq

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);
# }

lib.rs:

Order keeping job processing queue.

This module provides a multithreaded worker pool that processes tasks while keeping the order of outputs.

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
    }
}

let (tx, rx) = ordq::new(1024, vec![Add, Add]);

tx.send((1, 2));
tx.send((3, 4));
tx.send((5, 6));

tx.close();

assert_eq!(rx.recv(), Some(Ok(3)));
assert_eq!(rx.recv(), Some(Ok(7)));
assert_eq!(rx.recv(), Some(Ok(11)));
assert_eq!(rx.recv(), None);
assert_eq!(rx.recv(), None);

Dependencies

~0.6–1MB
~22K SLoC