英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论