2 releases

0.1.1 Sep 27, 2024
0.1.0 Jun 26, 2024

#979 in Asynchronous

Download history 30/week @ 2024-08-19 49/week @ 2024-08-26 32/week @ 2024-09-02 29/week @ 2024-09-09 48/week @ 2024-09-16 213/week @ 2024-09-23 85/week @ 2024-09-30 11/week @ 2024-10-07 22/week @ 2024-10-14 37/week @ 2024-10-21 23/week @ 2024-10-28 23/week @ 2024-11-04 3/week @ 2024-11-11 34/week @ 2024-11-18 31/week @ 2024-11-25 53/week @ 2024-12-02

121 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