Can someone explain the structure of a Pid (Process Identifier) in Erlang?

后端 未结 5 1982
走了就别回头了
走了就别回头了 2020-11-28 02:40

Can someone explain the structure of a Pid in Erlang?

Pids looks like this : , e.g. <0.30.0> , but i would like to kno

5条回答
  •  甜味超标
    2020-11-28 03:34

    If I remember this correctly the format is . 0 is current node much like a computer always has the hostname "localhost" to refer to itself. This is by old memory so it might not be 100% correct tough.

    But yes. You could build the pid with list_to_pid/1 for example.

    PidString = "<0.39.0>",
    list_to_pid(PidString) ! message.
    

    Of course. You just use whatever method you need to use to build your PidString. Probably write a function that generates it and use that instead of PidString like such:

    list_to_pid( make_pid_from_term({proc_name, Node}) ) ! message
    

提交回复
热议问题