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

Donald Steven t6sn7gt@REDACTED
Mon Feb 18 23:38:15 CET 2019


Got it!  Thanks Hugo, much appreciated.

Don

On 2/18/2019 1.45 PM, Hugo Mills wrote:
> On Mon, Feb 18, 2019 at 10:55:35AM -0500, Donald Steven 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.
>     Messages are processed singly and sequentially by any one
> process. Each process has a message queue, and the only time that a
> message comes off that queue is when receive is executed. The receive
> takes the first matching message off the queue and then runs the code
> for the branch matched. Only when another receive is encountered will
> the queue be looked at again.
>
>     So, basically, there's no pre-emption of the code within a process
> -- each process runs its code linearly and sequentially without
> interruption.
>
>     HTH,
>     Hugo.
>
>>    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