2个不稳定版本

0.2.0 2024年4月30日
0.1.0 2024年4月29日

#426 in 算法

Download history 1051/week @ 2024-05-01 3054/week @ 2024-05-08 2217/week @ 2024-05-15 2173/week @ 2024-05-22 1878/week @ 2024-05-29 1751/week @ 2024-06-05 1666/week @ 2024-06-12 1891/week @ 2024-06-19 2228/week @ 2024-06-26 2204/week @ 2024-07-03 2257/week @ 2024-07-10 1621/week @ 2024-07-17 1726/week @ 2024-07-24 1739/week @ 2024-07-31 1512/week @ 2024-08-07 1600/week @ 2024-08-14

6,955每月下载量

MIT/Apache

10KB
185

ordq

订单保持作业处理队列

示例

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:

订单保持作业处理队列。

此模块提供了一个多线程工作池,在处理任务的同时保持输出顺序。

示例

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

依赖项

~0.6–1.1MB
~23K SLoC