2 releases

0.1.1 Sep 27, 2024
0.1.0 Jun 26, 2024

#1185 in Asynchronous

Download history 31/week @ 2024-07-14 18/week @ 2024-08-11 30/week @ 2024-08-18 42/week @ 2024-08-25 46/week @ 2024-09-01 30/week @ 2024-09-08 47/week @ 2024-09-15 183/week @ 2024-09-22 114/week @ 2024-09-29 12/week @ 2024-10-06 22/week @ 2024-10-13 27/week @ 2024-10-20 34/week @ 2024-10-27

108 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–11MB
~93K SLoC