#priority-queue #queue #sequential #priority #heap #message-queue #multi-threading

ordered-channel

A channel that always receives messages in the correct order, even if they were sent out of order

3 stable releases

new 1.2.0 Mar 9, 2025
1.1.0 Jan 24, 2024
1.0.0 Jan 23, 2024

#132 in Concurrency

Download history 526/week @ 2024-11-20 592/week @ 2024-11-27 619/week @ 2024-12-04 782/week @ 2024-12-11 683/week @ 2024-12-18 386/week @ 2024-12-25 735/week @ 2025-01-01 836/week @ 2025-01-08 1089/week @ 2025-01-15 843/week @ 2025-01-22 1018/week @ 2025-01-29 831/week @ 2025-02-05 1019/week @ 2025-02-12 1071/week @ 2025-02-19 919/week @ 2025-02-26 1063/week @ 2025-03-05

4,276 downloads per month
Used in 13 crates (2 directly)

MIT/Apache

12KB
220 lines

Ordered channel

An MPSC blocking channel that returns messages in sorted sequential consecutive order (explicitly assigned to each message), regardless of the order they were sent in.

It's convenient for collecting order-sensitive results of parallel operations (fork-join iteration).

It's backed by a BinaryHeap that's used only when necessary to reorder the messages.


lib.rs:

Equivalent of mpsc or crossbeam-channel, but allows sending messages with an index associated with them, to be delivered in the specific indexed order.

This enables performing multi-threaded work without accidentally reordering results.

Results are delivered as soon as possible, with minimal buffering. Items received out of order are temporarily kept in a binary heap.

Dependencies

~76KB