[erlang-questions] Completing the thought (a question about receive)

Luke Bakken luke@REDACTED
Tue Feb 19 02:12:54 CET 2019


Hi Donald,

The short answer is yes, the code you want executed is always run.
Messages don't preempt already running statements in a process.

I was looking through the docs to see where this is explained and this
does a decent job
-http://erlang.org/doc/getting_started/conc_prog.html

On Mon, Feb 18, 2019 at 7:55 AM Donald Steven <t6sn7gt@REDACTED> wrote:
>
> In a receive block, will the code 'thought' be completed before things
> goes 'back' to the beginning of the block, or does another incoming
> message received before the completion of that thought 'interrupt' the
> thought.  If I haven't expressed that clearly, consider:
>
>      receive
>
>          {_, ComposerList, StartTime, XCoordinate, _, _, Distance,
> notdone} ->
>
>              some code I want executed
>              some code I want executed
>              some code I want executed;
>
>          {Base, _, StartTime, _, _, _, done}   ->
>
>              some code I want executed
>
>      end.
>
> =============================
>
> SO, will the three lines marked "some code I want executed" be executed
> always, or does a closely following message interrup it and send things
> back to the 'receive' (leaving some code perhaps not executed)?
>
> (...trying to find a problem...)
>
> Thanks.
>
> Don
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list