erlang - how to limit message queue or emulate it?

前端 未结 3 1766
Happy的楠姐
Happy的楠姐 2021-01-13 08:51

Right now I am doing Process ! Message, but as i googled a bit, a message queue size is only limited to memory. I have a tree of processes where leaves generate messages and

3条回答
  •  走了就别回头了
    2021-01-13 09:39

    The classical way of handling your second case is to include the Pid of the sending process in the message. This is very common for erlang messages which usually have the structure similar to {SendingPid,Data}. This allows the receiving to process both to see who sent the message and by using pattern matching within the receive to select from which process it wishes to receive messages.

    This is how erlang can multiplex messages from many different senders on one message queue and not be forced to handle all possible messages everywhere.

提交回复
热议问题