2 releases

0.1.1 Sep 27, 2024
0.1.0 Jun 26, 2024

#1106 in Asynchronous

Download history 29/week @ 2024-08-17 33/week @ 2024-08-24 53/week @ 2024-08-31 25/week @ 2024-09-07 46/week @ 2024-09-14 154/week @ 2024-09-21 139/week @ 2024-09-28 24/week @ 2024-10-05 22/week @ 2024-10-12 27/week @ 2024-10-19 34/week @ 2024-10-26 23/week @ 2024-11-02 1/week @ 2024-11-09 24/week @ 2024-11-16 35/week @ 2024-11-23 36/week @ 2024-11-30

97 downloads per month
Used in 8 crates (2 directly)

Apache-2.0

28KB
611 lines

SPSC Byte Channel

A single producer, single consumer asynchronous byte channel. The ByteReader and ByteWriter endpoints of the channel implement the Tokio tokio::io::AsyncRead and tokio::io::AsyncWrite traits respectively.

Running Cooperatively

Currently, types outside of of the Tokio crate cannot efficiently take part in the Tokio co-operative yielding mechanism. To work around this, the byte channels have an optional cooperation mechanism of their own that is enabled by the coop feature flag.

To use the cooperation mechanism, wrap any top level task futures with RunWithBudget. The extension trait BudgetedFutureExt adds methods to all futures to allocated a budget for the task. The budget is shared between all byte channels within that future.

Whenever any of those channels makes progress it will consume a unit of budget. A channel that exhausts the budget will reset the budget and immediately yield to the runtime (after rescheduling itself).

Dependencies

~3.5–9.5MB
~91K SLoC