pub fn new<A: AsRef<[Arc<Waker>]>, B: AsRef<[Arc<Waker>]>>(
        a_wakers: A,
        b_wakers: B,
        capacity: usize,
    ) -> (Vec<Queues<T, U>>, Vec<Queues<U, T>>) {
        let mut a_wakers = a_wakers.as_ref().to_vec();
        let mut b_wakers = b_wakers.as_ref().to_vec();

        // T messages are sent to side b, so we have a `WakingSender` for each
        // side b queue.

        // these will be used in side a to transmit
        let mut a_tx = Vec::<WakingSender<TrackedItem<T>>>::with_capacity(b_wakers.len());

        // these will be used in side b to receive
        let mut b_rx = Vec::<Receiver<TrackedItem<T>>>::with_capacity(b_wakers.len());

        for waker in b_wakers.drain(..) {
            let (s, r) = bounded(capacity);
            let s = WakingSender {
                inner: s,
                waker,
                needs_wake: false,
            };
            a_tx.push(s);
            b_rx.push(r);
        }

        // T messages are sent to side b, so we have a `WakingSender` for each
        // side a queue.

        // these will be used in side b to transmit
        let mut b_tx = Vec::<WakingSender<TrackedItem<U>>>::with_capacity(a_wakers.len());

        // these will be used in side a to receive
        let mut a_rx = Vec::<Receiver<TrackedItem<U>>>::with_capacity(a_wakers.len());

        for waker in a_wakers.drain(..) {
            let (s, r) = bounded(capacity);
            let s = WakingSender {
                inner: s,
                waker,
                needs_wake: false,
            };
            b_tx.push(s);
            a_rx.push(r);
        }

        let mut a = Vec::new();
        let mut b = Vec::new();

        for (id, receiver) in a_rx.drain(..).enumerate() {
            a.push(Queues {
                senders: a_tx.clone(),
                receiver,
                rng: ChaCha20Rng::from_entropy(),
                distr: Uniform::new(0, a_tx.len()),
                id,
            })
        }

        for (id, receiver) in b_rx.drain(..).enumerate() {
            b.push(Queues {
                senders: b_tx.clone(),
                receiver,
                rng: ChaCha20Rng::from_entropy(),
                distr: Uniform::new(0, b_tx.len()),
                id,
            })
        }

        (a, b)
    }
/// Construct the queues for communicating between both sides. Side `a`
/// sends items of type `T` to side `b`. Side `b` sends items of type `U` to
/// side `a`.
///
/// To construct this type, you must pass the `mio::Waker`s registered for
/// each `mio::Poll` instance for side `a` and side `b`. This is required so
/// that the queues can be used within the event loops and wakeups for the
/// receivers can be issued by the senders.
///
/// Since bounded queues are used internally, the capacity is the maximum
/// number of pending items each receiver can have. For example, if side A
/// has 4 queues, and a capacity of 1024*4 => 4096 items of type U may be
/// pending.
///
/// NOTE: the return vectors maintain the ordering of the wakers that were
/// provided. Care must be taken to ensure that the corresponding queues are
/// given to the event loop with the corresponding waker.
Construct the queues for communicating between both sides.



Since bounded queues are used internally, the capacity is the maximum
number of pending items each receiver can have. For example, if side A
has 4 queues, and a capacity of 1024*4 => 4096 items of type U may be
pending.

the return vectors maintain the ordering of the wakers that were
provided. Care must be taken to ensure that the corresponding queues are
given to the event loop with the corresponding waker.
Construct the queues for communicating between both sides . Since bounded queues are used internally the capacity is the maximum number of pending items each receiver can have . For example if side A has 4 queues and a capacity of 1024 * 4 = > 4096 items of type U may be pending . the return vectors maintain the ordering of the wakers that were provided . Care must be taken to ensure that the corresponding queues are given to the event loop with the corresponding waker .
pub fn new<A: AsRef<[Arc<Waker>]>, B: AsRef<[Arc<Waker>]>>(
        a_wakers: A,
        b_wakers: B,
        capacity: usize,
    ) -> (Vec<Queues<T, U>>, Vec<Queues<U, T>>) {
        let mut a_wakers = a_wakers.as_ref().to_vec();
        let mut b_wakers = b_wakers.as_ref().to_vec();
        // T messages are sent to side b, so we have a `WakingSender` for each
        // side b queue.
        // these will be used in side a to transmit
        let mut a_tx = Vec::<WakingSender<TrackedItem<T>>>::with_capacity(b_wakers.len());
        // these will be used in side b to receive
        let mut b_rx = Vec::<Receiver<TrackedItem<T>>>::with_capacity(b_wakers.len());
        for waker in b_wakers.drain(..) {
            let (s, r) = bounded(capacity);
            let s = WakingSender {
                inner: s,
                waker,
                needs_wake: false,
            };
            a_tx.push(s);
            b_rx.push(r);
        }
        // T messages are sent to side b, so we have a `WakingSender` for each
        // side a queue.
        // these will be used in side b to transmit
        let mut b_tx = Vec::<WakingSender<TrackedItem<U>>>::with_capacity(a_wakers.len());
        // these will be used in side a to receive
        let mut a_rx = Vec::<Receiver<TrackedItem<U>>>::with_capacity(a_wakers.len());
        for waker in a_wakers.drain(..) {
            let (s, r) = bounded(capacity);
            let s = WakingSender {
                inner: s,
                waker,
                needs_wake: false,
            };
            b_tx.push(s);
            a_rx.push(r);
        }
        let mut a = Vec::new();
        let mut b = Vec::new();
        for (id, receiver) in a_rx.drain(..).enumerate() {
            a.push(Queues {
                senders: a_tx.clone(),
                receiver,
                rng: ChaCha20Rng::from_entropy(),
                distr: Uniform::new(0, a_tx.len()),
                id,
            })
        }
        for (id, receiver) in b_rx.drain(..).enumerate() {
            b.push(Queues {
                senders: b_tx.clone(),
                receiver,
                rng: ChaCha20Rng::from_entropy(),
                distr: Uniform::new(0, b_tx.len()),
                id,
            })
        }
        (a, b)
    }
pub fn new < A : AsRef < [ Arc < Waker > ] > , B : AsRef < [ Arc < Waker > ] > > ( a_wakers : A , b_wakers : B , capacity : usize , ) -> ( Vec < Queues < T , U > > , Vec < Queues < U , T > > ) { let mut a_wakers = a_wakers . as_ref ( ) . to_vec ( ) ; let mut b_wakers = b_wakers . as_ref ( ) . to_vec ( ) ; // T messages are sent to side b, so we have a `WakingSender` for each // side b queue. // these will be used in side a to transmit let mut a_tx = Vec :: < WakingSender < TrackedItem < T > > > :: with_capacity ( b_wakers . len ( ) ) ; // these will be used in side b to receive let mut b_rx = Vec :: < Receiver < TrackedItem < T > > > :: with_capacity ( b_wakers . len ( ) ) ; for waker in b_wakers . drain ( .. ) { let ( s , r ) = bounded ( capacity ) ; let s = WakingSender { inner : s , waker , needs_wake : false , } ; a_tx . push ( s ) ; b_rx . push ( r ) ; } // T messages are sent to side b, so we have a `WakingSender` for each // side a queue. // these will be used in side b to transmit let mut b_tx = Vec :: < WakingSender < TrackedItem < U > > > :: with_capacity ( a_wakers . len ( ) ) ; // these will be used in side a to receive let mut a_rx = Vec :: < Receiver < TrackedItem < U > > > :: with_capacity ( a_wakers . len ( ) ) ; for waker in a_wakers . drain ( .. ) { let ( s , r ) = bounded ( capacity ) ; let s = WakingSender { inner : s , waker , needs_wake : false , } ; b_tx . push ( s ) ; a_rx . push ( r ) ; } let mut a = Vec :: new ( ) ; let mut b = Vec :: new ( ) ; for ( id , receiver ) in a_rx . drain ( .. ) . enumerate ( ) { a . push ( Queues { senders : a_tx . clone ( ) , receiver , rng : ChaCha20Rng :: from_entropy ( ) , distr : Uniform :: new ( 0 , a_tx . len ( ) ) , id , } ) } for ( id , receiver ) in b_rx . drain ( .. ) . enumerate ( ) { b . push ( Queues { senders : b_tx . clone ( ) , receiver , rng : ChaCha20Rng :: from_entropy ( ) , distr : Uniform :: new ( 0 , b_tx . len ( ) ) , id , } ) } ( a , b ) }
Construct the queues for communicating between both sides.
Construct the queues for communicating between both sides .
a_wakers
A
b_wakers
B
capacity
usize
a_wakers
A
b_wakers
B
capacity
usize