Hi all,<br><br>I want to know what is the current implementation of Erlang's receive statement.<br><br>I need to implement a system where two priorities can be given to messages (high and normal). I need to, first, process all high priority messages and then return the first normal priority one (if any). I wonder which its best implementation can be:<br>
<br>process_all_messages()-><br>      receive  <br>            {high_priority, Message} ->  % <--- Pattern1<br>                        process_message(Message),<br>                        process_all_messages()<br>
     after <br>           0 -><br>             receive<br>                       {normal_priority, Message} -> % <--- Pattern2<br>                                              Message<br>             after  <br>                    0 -><br>
                       no_messages<br>            end<br>     end.<br> <br><br>This function will be called periodically and I need to know if this implementation will always go through all the message in the mailbox (i.e. it will try to match Pattern1 to the messages at the beginning of the mailbox over and over again).<br>
<br>Is there any recent improvement? <br><br><br>Will I get any gain by implementing my own priority queue?<br><br><br>Thanks a lot,<br>Álvaro<br>         <br>      <br><br>