Goroutine能像Erlang一样透明地在多个主机上生成进程吗?

huangapple go评论81阅读模式
英文:

Can goroutine like erlang spawn process across multiple hosts transparently?

问题

据说,如果配置了erlang的cookie设置,erlang的进程可以在不同的机器上运行,对调用者来说是透明的。那么goroutine能像这样运行吗?

英文:

It is said that if configured erlang with cookie setting, the erlang's process could be run across different machines, and this is transparent to the caller.
Is that possible for goroutine run like this?

答案1

得分: 7

这不是语言的一个特性。然而,由于语言中没有办法询问关于goroutine的信息(例如获取线程ID或从不同的goroutine控制它们,就像其他一些语言中那样),只要你能够建立透明的通信机制(例如通过网络工作的通道),你就可以创建类似的效果。实际上,Go语言的创始人之一Rob Pike过去曾尝试过一个名为“netchan”的包来实现这个目的,但是他没有找到合适的语义,所以他还没有发布最终版本。不过,他仍然对这个问题很感兴趣,并且这与Go语言对抽象的处理方式是一致的。

英文:

This is not a feature of the language, no. However, since there's no way in the language to ask about goroutines (for example, to get a thread ID or control them from a different goroutine like in some other languages), as long as you could set up transparent communication mechanisms (for example, channels that work over the network), you could create a similar effect. In fact, Rob Pike, one of the creators of Go, has toyed around in the past with a package he called "netchan" to do exactly this, but couldn't get the semantics right, and so he hasn't published a finalized version yet. It's definitely something he's still interested in, though, and would certainly be consistent with the Go approach to abstraction.

huangapple
  • 本文由 发表于 2014年9月3日 20:37:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/25644534.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定