<div dir="ltr">Hi all,<br><br>I have an example of a receive where I don't seem to be able to use the usual "dump any unrecognized messages" catch-all clause. I think it is also an example where channels could be useful, but the main question is whether I am missing the obvious or not.<br>
<br>I have a process that takes {input, Data} messages from its mailbox and processes them (not necessarily one at a time). Flow control is implemented as a pair of 'start'/'stop' messages. The way I implemented the main loop is (simplified)<br>
<br>  receive<br>    start->Running = true, loop();<br>    stop->Running = false, loop()<br>  after 0 -> <br>      if Running -> process_one_step(), loop();<br>         true -> loop()<br>      end<br>  end,<br>
<br>where the process_one_step() function may call<br><br>  receive<br>    {input, Data} -> ...<br>  end<br><br>one or several times (it is configurable by the clients).<br><br>It seems to me that there is no place where I can put a '_->...;' clause without creating problems. So I'd like to ask if anyone sees another way to structure this that will allow rogue messages to be discarded.<br>
<br>------<br>A solution that requires an EEP :-) is to introduce an extension to the receive statement that will explicitly  keep matched messages  in the  mailbox. For example<br><br>receive <br>  Pattern -> keep(), loop();<br>
  Msg ->  process(Msg), loop() <br>end<br><br>keep() is the extension that says "leave the message in the mailbox and proceed". This way process() will be called with all messages except those matching Pattern<br>
<br>Would something like that be useful, or are there already ways to achieve the same effect?<br><br>best regards,<br>Vlad<br><br></div>