<div dir="ltr">
<font face="monospace, monospace" style="color:rgb(34,34,34);font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">I was reading the book of Mr. Joe Armstrong "Programming Erlang 2nd ed.",</font><div style="color:rgb(34,34,34);font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace">when I reached the section about selective receive. </font></div><div style="color:rgb(34,34,34);font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace">He explained it very clearly. So, based on his explanation I decided to</font></div><div style="color:rgb(34,34,34);font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace">make a flowchart. I would like to share it with you. Comments are welcome.</font></div>
<font face="monospace, monospace"><br></font><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><div><font face="monospace, monospace"> +-----------------+</font></div><div><font face="monospace, monospace"> | Enter receive. | ** Timer may have already been elapsed</font></div><div><font face="monospace, monospace"> | Start timer | when entering this state.</font></div><div><font face="monospace, monospace"> +------+----------+</font></div><div><font face="monospace, monospace"> |</font></div><div><font face="monospace, monospace"> +-----v------+ +--------------------------------+ +-------------------+</font></div><div><font face="monospace, monospace"> | is mailbox | Yes | suspend process until |timer elapsed | evaluate |</font></div><div><font face="monospace, monospace">+------> empty? +------------> a new message is put in mailbox+--------------> expressionsTimeout|</font></div><div><font face="monospace, monospace">| | | | or timer has elapsed** | | |</font></div><div><font face="monospace, monospace">| +------------+ +-----+--------------------------+ +--------+----------+</font></div><div><font face="monospace, monospace">| |No | |</font></div><div><font face="monospace, monospace">| +------v----------------+ |new msg arrived |</font></div><div><font face="monospace, monospace">| | take the head message | | |</font></div><div><font face="monospace, monospace">| | from the mailbox <--------+ |</font></div><div><font face="monospace, monospace">| +------+----------------+ |</font></div><div><font face="monospace, monospace">| | |</font></div><div><font face="monospace, monospace">| +-----v-------------+ +---------------+ +-------------+ |</font></div><div><font face="monospace, monospace">| | match the message +---->remove message +---->evaluate +------------+ |</font></div><div><font face="monospace, monospace">| | against pattern1 |Yes |from mailbox | |expressions1 | | |</font></div><div><font face="monospace, monospace">| +-------------------+ +---------------+ +-------------+ | |</font></div><div><font face="monospace, monospace">| |No | |</font></div><div><font face="monospace, monospace">| | +-----v---------v--------------------+</font></div><div><font face="monospace, monospace">| +-----v-------------+ +---------------+ +-------------+ | if any messages have been put into |</font></div><div><font face="monospace, monospace">| | match the message +---->remove message +---->evaluate +------> the save queue, are reentered |</font></div><div><font face="monospace, monospace">| | against pattern2 |Yes |from mailbox | |expressions2 | | into the mailbox |</font></div><div><font face="monospace, monospace">| +-------------------+ +---------------+ +-------------+ +-----^---------+--------------------+</font></div><div><font face="monospace, monospace">| |No | |</font></div><div><font face="monospace, monospace">| | | |</font></div><div><font face="monospace, monospace">| +-----v-------------+ +---------------+ +-------------+ | |</font></div><div><font face="monospace, monospace">| | match the message +---->remove message +---->evaluate +------------+ |</font></div><div><font face="monospace, monospace">| | against pattern3 |Yes |from mailbox | |expressions3 | |</font></div><div><font face="monospace, monospace">| +-------------------+ +---------------+ +-------------+ |</font></div><div><font face="monospace, monospace">| |No |</font></div><div><font face="monospace, monospace">| | |</font></div><div><font face="monospace, monospace">| +-----v------------------------------+ |</font></div><div><font face="monospace, monospace">| | message is removed from the mailbox| |</font></div><div><font face="monospace, monospace">+------+ and put into a "save queue" | |</font></div><div><font face="monospace, monospace"> | | |</font></div><div><font face="monospace, monospace"> +------------------------------------+ |</font></div><div><font face="monospace, monospace"> |</font></div><div><font face="monospace, monospace"> +------------------+ |</font></div><div><font face="monospace, monospace"> | Exit receive. <--------------------------------------------------------------+</font></div><div><font face="monospace, monospace"> | Timer is cleared.|</font></div><div><font face="monospace, monospace"> +------------------+</font></div></div><div><br></div></div>