fn try_receive_all<F>(&self, receiver: usize, mut cb: F) -> bool
    where
        F: FnMut(T),
    {
        if !self.ready_to_receive(receiver) {
            return false;
        }

        for sender in 0..self.npeers {
            let mut data = Default::default();
            swap(
                &mut data,
                &mut *self.mailbox(sender, receiver).lock().unwrap(),
            );
            cb(data);
            self.receiver_counters[receiver].fetch_sub(1, Ordering::SeqCst);
            let old_counter = self.sender_counters[sender].fetch_add(1, Ordering::SeqCst);
            if old_counter >= self.npeers - 1 {
                // This can be a spurious callback if the following thread interleaving occurs:
                // 1. Another receiver increments the sender's counter to `npeers`.
                // 2. The sender starts transmitting messages, writing `receiver`'s mailbox
                // first    (counter drops to `npeers-1`)
                // 3. `receiver` is unblocked and retrieves its message, bumping the counter
                //    back to `npeers` and generating a spurious sender callback in the
                // following    line.
                if let Some(cb) = self.sender_callbacks[sender].get() {
                    cb()
                }
            }
        }

        true
    }
/// Read all incoming messages for `receiver`.
///
/// Values are passed to callback function `cb`.
///
/// # Errors
/// Fails if at least one of the receiver's incoming mailboxes empty.
Read all incoming messages for `receiver`.
Values are passed to callback function `cb`.
Read all incoming messages for ` receiver ` . Values are passed to callback function ` cb ` .
fn try_receive_all<F>(&self, receiver: usize, mut cb: F) -> bool
    where
        F: FnMut(T),
    {
        if !self.ready_to_receive(receiver) {
            return false;
        }
        for sender in 0..self.npeers {
            let mut data = Default::default();
            swap(
                &mut data,
                &mut *self.mailbox(sender, receiver).lock().unwrap(),
            );
            cb(data);
            self.receiver_counters[receiver].fetch_sub(1, Ordering::SeqCst);
            let old_counter = self.sender_counters[sender].fetch_add(1, Ordering::SeqCst);
            if old_counter >= self.npeers - 1 {
                // This can be a spurious callback if the following thread interleaving occurs:
                // 1. Another receiver increments the sender's counter to `npeers`.
                // 2. The sender starts transmitting messages, writing `receiver`'s mailbox
                // first    (counter drops to `npeers-1`)
                // 3. `receiver` is unblocked and retrieves its message, bumping the counter
                //    back to `npeers` and generating a spurious sender callback in the
                // following    line.
                if let Some(cb) = self.sender_callbacks[sender].get() {
                    cb()
                }
            }
        }
        true
    }
fn try_receive_all < F > ( & self , receiver : usize , mut cb : F ) -> bool where F : FnMut ( T ) , { if ! self . ready_to_receive ( receiver ) { return false ; } for sender in 0 .. self . npeers { let mut data = Default :: default ( ) ; swap ( & mut data , & mut * self . mailbox ( sender , receiver ) . lock ( ) . unwrap ( ) , ) ; cb ( data ) ; self . receiver_counters [ receiver ] . fetch_sub ( 1 , Ordering :: SeqCst ) ; let old_counter = self . sender_counters [ sender ] . fetch_add ( 1 , Ordering :: SeqCst ) ; if old_counter >= self . npeers - 1 { // This can be a spurious callback if the following thread interleaving occurs: // 1. Another receiver increments the sender's counter to `npeers`. // 2. The sender starts transmitting messages, writing `receiver`'s mailbox // first    (counter drops to `npeers-1`) // 3. `receiver` is unblocked and retrieves its message, bumping the counter //    back to `npeers` and generating a spurious sender callback in the // following    line. if let Some ( cb ) = self . sender_callbacks [ sender ] . get ( ) { cb ( ) } } } true }
Read all incoming messages for `receiver`.
Read all incoming messages for ` receiver ` .
&self
receiver
usize
cb
F
errors
Fails if at least one of the receiver's incoming mailboxes empty.
Fails if at least one of the receiver ' s incoming mailboxes empty .