Does a buffered channel conform to the actor model?

xuanbao · 2015-03-30 19:36:08 · 1604 次点击    
这是一个分享于 2015-03-30 19:36:08 的资源,其中的信息可能已经有所发展或是发生改变。

Hi Gophers; theory question here!

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?

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't seem to support messages over network, is this something that will be added or are there any good 3rd party libs for this?

Thanks for reading :smile:

TD;LR: do GoRoutines with buffered channels conform to the actor model rather than CSP?


评论:

Ainar-G:

I can kinda answer your bonus question. There was a netchan package for emulating buffered channels over the network, but it's deprecated for some reason. There is also std's net/rpc package that can be used for inter-machine communication.

As for your main question, I don't know enough about actor model, so I can't really answer that.

roveboat:

There's libchan these days. With a quick glimpse, buffering would need to be implemented manually.

tcolgate:

Without some further framework actually enforcing the axioms of the actor model then no. With such a framework, then, well yes (though it's not obvious that buffering really has anything to do with it). Even on a simpler level you don't have a built in notion of being able to identify who sent something to you (I think that's part of the actor model, you know who sent you something).

Personally, I'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't be too eager to use buffered channels.

I believe netchan was removed from before 1.0 as it wasn'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't going to get channel semantics without a lot of effort.

CzarSkye:

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.

99% of the time the CSP model works great for me, I love that channel messages offers simple synchronization of go routines. I don'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.


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

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