Does a buffered channel conform to the actor model?

xuanbao · · 1473 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi Gophers; theory question here! </p> <p>Using goroutines and channels is concurrecy under the CSP model. If I where to use a buffered channel however, would this make it fit under the banner of the actor model?</p> <p>Bonus questions: I like using the actor model (mainly with Java/Akka) and the CSP model (with Go). Akka allows actors to easily message each other over a network, making horizontal distribution easy. Go standard libs doesn&#39;t seem to support messages over network, is this something that will be added or are there any good 3rd party libs for this?</p> <p>Thanks for reading :)</p> <p>TD;LR: do GoRoutines with buffered channels conform to the actor model rather than CSP?</p> <hr/>**评论:**<br/><br/>Ainar-G: <pre><p>I can kinda answer your bonus question. There was a <a href="https://godoc.org/golang.org/x/exp/old/netchan" rel="nofollow">netchan</a> package for emulating buffered channels over the network, but it&#39;s deprecated for some reason. There is also std&#39;s <a href="http://golang.org/pkg/net/rpc/" rel="nofollow">net/rpc</a> package that can be used for inter-machine communication.</p> <p>As for your main question, I don&#39;t know enough about actor model, so I can&#39;t really answer that.</p></pre>roveboat: <pre><p>There&#39;s <a href="https://github.com/docker/libchan" rel="nofollow">libchan</a> these days. With a quick glimpse, buffering would need to be implemented manually.</p></pre>tcolgate: <pre><p>Without some further framework actually enforcing the axioms of the actor model then no. With such a framework, then, well yes (though it&#39;s not obvious that buffering really has anything to do with it). Even on a simpler level you don&#39;t have a built in notion of being able to identify who sent something to you (I think that&#39;s part of the actor model, you know <em>who</em> sent you something).</p> <p>Personally, I&#39;d say it makes more sense to focus on the idomatic use of the language, which is (fairly obviously) closer to CSP, anyway. And don&#39;t be too eager to use buffered channels.</p> <p>I believe netchan was removed from before 1.0 as it wasn&#39;t felt sufficiently complete, though there is a strong desire to put it back. grpc with streams and contexts might provide a better toolset to build on that the inbuilt rpc package, but you still aren&#39;t going to get channel semantics without a lot of effort.</p></pre>CzarSkye: <pre><p>yes, I think you might be right there, I overlooked sender identification within a message, which is present (and necessary) in the akka framework I use.</p> <p>99% of the time the CSP model works great for me, I love that channel messages offers simple synchronization of go routines. I don&#39;t think it would be too hard at all to implement the actor model in go though, I may have a go as an interesting side project, and for some use cases it is just easier to use.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1473 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传