Module bt_a2dp::permits

source ·
Expand description

Permits counting for reservations. A collection which hands out Permits, of which a limited number of are allowed exist at once. Permits can be granted immediately, or can be reserved in first-come-first-serve order, with a Future which resolves to a Permit once one becomes available.

Permits are released upon drop and will be automatically handed off to the next reservation or returned to the available pool if no one is waiting.

Permits can be revokable by providing a function which will return a valid Permit when called. That function can also make a reservation for a future Permit if desired. (see examples in tests)

A client can take a permit (revoking one if necessary), by using Permits::take. A client can also seize all permits, taking out all permits left unclaimed and revoking all revokable permits.

Permits taken or seized are not revokable.