My thread does its job in a loop: collect all pending signals, than process:
'mloop: loop {
// wait for signal
match rx.recv().unwrap() {
MySignal::Stop => break 'mloop,
// all other cases
}
// process all other signals
match rx.try_iter() {
MySignal::Stop => break 'mloop,
// all other cases
}
// do some processing
}
The problem is a need to double the match with its body.
Am I doing this correctly? Unfortunately I do not find Receiver implementing function "block for a signal, but if there are more in a queue, iterate over them."