Macro pool

Source
macro_rules! pool {
    ($vis:vis $name:ident: [$ty:ty; $n:expr], $wn:expr) => { ... };
}
Expand description

Create a item pool of a given type and size, as well as a waker pool of a given length.

The waker pool is used to wake up tasks waiting for an item to become available in the data pool. Its length should be at least the number of tasks that can be waiting for an item at the same time. Example:

use async_pool::{pool, Box};

#[derive(Debug)]
#[allow(dead_code)]
struct Packet(u32);

pool!(PacketPool: [Packet; 4], 2); // Item pool of 4 Packet instances, waker pool of 2 wakers