Macro worker_pool::try_recv_break
source · [−]macro_rules! try_recv_break {
( $rx:tt ) => { ... };
}Expand description
Wrapper around Receiver<DownMsg<T>>::try_recv, meant to be used in a loop:
- if
StoporDisconnectedis received, breaks from the parent loop - if
Pauseis received, then block untilContinueis received; anyOthermessage will be ignored between the two - if
ContinueorEmptyis received, returnsNone - if
Other(x)is received, returnsSome(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
}
}
});