pmpmc
Priority Multi Consumer Multi Producer Channel
This is a simple implementation of a multi producer multi consumer channel for elements that implement the Ord trait, which replaces the typical rx.recv() with rx.recv_greatest(). It is basically just using the typical Arc<Mutex<>> wrapper to push to a std::collections::BinaryHeap from one thread and to pop from that heap in another thread.
Example
use pmpmc;
let = pmpmc;
let tx_new = tx.clone;
let rx_new = rx.clone;
let _ = spawn
.join;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
I am using it for automatically scheduling tasks (workers now pull tasks off the channel in order of priority) but you can use it any time you want to push to a list from one or more threads and sort the list before receiving on another thread.
License: MIT