1 unstable release

0.1.0 Jun 26, 2024

#921 in Asynchronous

Download history 100/week @ 2024-06-20 48/week @ 2024-06-27 24/week @ 2024-07-04 19/week @ 2024-07-11 15/week @ 2024-07-18 10/week @ 2024-08-08 28/week @ 2024-08-15 32/week @ 2024-08-22 43/week @ 2024-08-29

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

Apache-2.0

27KB
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–10MB
~92K SLoC