Open source projects that uses channels for reading purpose.

blov · 2018-03-10 18:30:11 · 563 次点击    
这是一个分享于 2018-03-10 18:30:11 的资源,其中的信息可能已经有所发展或是发生改变。

Hello All,

I'm reading Golang and want to check if there are any open source project which uses channels in their code base. I would prefer any such libraries/code which will allow the beginner to pick and understand how channels work in real world.

Thanks for your help.


评论:

HappyVictory:

its typically used for threading;

threading is most commonly used when you need 2 cpu loops, ex:

go DrawAllUI()
go Sort1millionRows()
go HandleUserInputWithNoLag()

for example if you sort 1 million rows of a array while your UI is drawing anything: the mouse would stop responding and the UI would stop drawing

typically MS windows and other UI's use 'message passing' to handle events between threads.... which is like javascript events, or callbacks:

sendMessage(MyApp, WM_EventSomething, DATA1, DATA2)
//is roughly equivalent to
foo.eventnotify('click', {data: asdf})

and these are cross-thread communication

but now you can use channels too to communicate between thread:

events <- someObjectGenerator('click', map[string]int{"x" : 0, "y" : 0}) 

the other main use is to share data between threads ; because while two threads read the same memory block; if both write the same memory at the same time it will corrupt the data

Killing_Spark:

https://github.com/killingspark/restic-cronned

The jobs take advantage of channels to get triggered.

caseynashvegas:

Definitely not perfect code but I'm using channels in a simple chat server here https://github.com/caseylmanus/runtelchat

anonfunction:

https://github.com/klauspost/pgzip/search?q=chan

antoaravinth:

Wow, thanks. Looks neat and at the same time eligible for the beginners.

boyter:

Been using them in a pipeline for a replacement for cloc I have been working on https://github.com/boyter/scc

I’m a totally new Go developer so nothing fancy is going on in there. I suspect if you are new to it it’s likely to help with understanding.


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

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