[erlang-questions] Process Message Queues

Per Melin per.melin@REDACTED
Fri Apr 23 21:52:16 CEST 2010


On Fri, Apr 23, 2010 at 6:49 PM, Evans, Matthew <mevans@REDACTED> wrote:
> (scm@REDACTED)1> Pid = spawn(fun() -> receive message_a -> error_logger:info_msg("Got message_a~n"); message_b -> error_logger:info_msg("got message_b~n"); message_c -> receive message_d -> error_logger:info_msg("Got message_d~n") end end end).
> <0.19842.0>
> (scm@REDACTED)2> Pid ! hello.
> hello
> (scm@REDACTED)3> Pid ! goodbye.
> goodbye
> (scm@REDACTED)4> Pid ! message_d.
> message_d
> (scm@REDACTED)5> Pid ! message_e.
> message_e
> (scm@REDACTED)6> erlang:process_info(Pid,message_queue_len).
> {message_queue_len,0}

Put the first line with the spawn in a function in a module. Compile
it and start your experiment by calling the function. The rest should
then behave as expected.


More information about the erlang-questions mailing list