Does Erlang always copy messages between processes on the same node?

后端 未结 4 763
暗喜
暗喜 2021-01-02 04:17

A faithful implementation of the actor message-passing semantics means that message contents are deep-copied from a logical point-of-view, even for immutable types.

4条回答
  •  耶瑟儿~
    2021-01-02 05:06

    As has been mentioned here and in other questions current versions of Erlang basically copy everything except for larger binaries. In older pre-SMP times it was feasible to not copy but pass references. While this resulted in very fast message passing it created other problems in the implementation, primarily it made garbage collection more difficult and complicated implementation. I think that today passing references and having shared data could result in excessive locking and synchronisation which is, of course, not a Good Thing.

提交回复
热议问题