[erlang-questions] Process Message Queues

Per Melin <>
Fri Apr 23 21:52:16 CEST 2010


On Fri, Apr 23, 2010 at 6:49 PM, Evans, Matthew <> wrote:
> ()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>
> ()2> Pid ! hello.
> hello
> ()3> Pid ! goodbye.
> goodbye
> ()4> Pid ! message_d.
> message_d
> ()5> Pid ! message_e.
> message_e
> ()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