-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
golang version: prime sieve 理解笔记 #8
Comments
下面说理解。 本质上这个程序就是个Daisy-chain,从上面的图可以看出,也和之前rob pike在go concurrency patterns里介绍的一样。 这个chain的源头是Generate(),然后将数据流传给Filter-1,进行过滤后,将数据流传递给Filter-2 ,以此类推 并且在每次数据流传递的时候,取第一个(素数)传给main并输出 |
这是mit 6.828里lab1的一个作业,求一定数范围内的素数。用的也是上面的素数筛选法,并且要求并发实现
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
代码如下:
理解golang的并发模式,在我看来,有两种方式:宏观的和微观的
所谓宏观,就是不去在意程序的执行逻辑和顺序,将关注放在程序的实现算法,并把无缓冲channel当作一个在不同goroutines之间传递消息的同步pipe。
所谓微观,就是利用分析工具,来将程序的执行逻辑可视化。譬如这篇非常好的文章:go_concurrency_visualize,就是利用分析工具+WebGL制作3D可视化动画,将程序的运行过程给形象的展示了出来。
The text was updated successfully, but these errors were encountered: