12 releases (breaking)

0.9.3 Dec 22, 2022
0.9.2 Jun 1, 2022
0.9.1 Mar 16, 2022

#810 in Concurrency

Download history 9/week @ 2023-10-23 24/week @ 2023-10-30 7/week @ 2023-11-06 4/week @ 2023-11-13 30/week @ 2023-11-20 56/week @ 2023-11-27 2/week @ 2023-12-04 16/week @ 2023-12-11 4/week @ 2023-12-18 28/week @ 2023-12-25 14/week @ 2024-01-01 5/week @ 2024-01-08 4/week @ 2024-01-15 13/week @ 2024-01-22 26/week @ 2024-01-29 7/week @ 2024-02-05

51 downloads per month
Used in dirinventory

MIT/Apache

23KB
486 lines

Description

A multi-producer multi-consumer priority queue with some special features.

Allows threads to send and receive messages ordered by priority.

While a thread is processing a message, received messages can be protected by a guard this keeps the queue in a non-drained state the thread may send new messages to the queue to be processed. Once the queue becomes empty and all guards are dropped a single 'Drained' message is generated to notify (one of) the receivers that no more data is to be expected.

When performance is more important than exact priority order threads can hold a 'stash' to temporary store messages to be send. When the queue is contended messages will be put on this stash instead. Once the thread gets the lock on the queue the stash will be moved over to the queue.

Dependencies

~0.4–6MB
~11K SLoC