macro_rules! try_recv_break {
    ( $rx:tt ) => { ... };
}
Expand description

Wrapper around Receiver<DownMsg<T>>::try_recv, meant to be used in a loop:

  • if Stop or Disconnected is received, breaks from the parent loop
  • if Pause is received, then block until Continue is received; any Other message will be ignored between the two
  • if Continue or Empty is received, returns None
  • if Other(x) is received, returns Some(x)

Example

pool.execute(|_tx, rx| {
    loop {
        if let Some(msg) = worker_pool::try_recv_break!(rx) {
            // Handle msg
        } else {
            // Do something else in the meantime
        }
    }
});