Erlang 消息循环
Erlang 中的消息循环如何工作,在处理消息时它们是否同步?
据我了解,循环将从“接收”消息开始,然后执行某些操作并进行循环的另一次迭代。
那么一定要同步吗?正确的?
如果多个客户端将消息发送到同一个消息循环,那么所有这些消息都会排队并依次执行,或者?
要并行处理多个消息,您必须在不同的进程中生成多个消息循环,对吧?
还是我误解了这一切?
How does message loops in erlang work, are they sync when it comes to processing messages?
As far as I understand, the loop will start by "receive"ing a message and then perform something and hit another iteration of the loop.
So that has to be sync? right?
If multiple clients send messages to the same message loop, then all those messages are queued and performed one after another, or?
To process multiple messages in parallell, you would have to spawn multiple message loops in different processes, right?
Or did I misunderstand all of it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
发送消息是异步的。处理消息是同步的 - 一次接收一条消息 - 因为每个进程都有自己的(且只有一个)邮箱。
Sending a message is asynchronous. Processing a message is synchronous - one message is receive'd at a time - because each process has its own (and only one) mailbox.
来自手册(Erlang 并发
因此,您可以使用正则表达式创建 prio,但并发性是通过多个进程完成的。
From the manual (Erlang concurrency
So you could create prios with the regex, but the concurrency is done via multiple processes.