Skip to content
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

c04/c04_10 #46

Open
utterances-bot opened this issue Jul 22, 2022 · 5 comments
Open

c04/c04_10 #46

utterances-bot opened this issue Jul 22, 2022 · 5 comments

Comments

@utterances-bot
Copy link

4.10 学习 Go 协程:万能的通道模型(公式) — Go编程时光 1.0.0 documentation

https://golang.iswbm.com/c04/c04_10.html

Copy link

一个发送者,N 个接收者
这里 具备广播功能 只能是无缓冲对列和举例不符合, 这里应该只是stopCh的关闭被多个select监听到了,和是否有缓冲无关

Copy link

ZGY1999 commented Feb 15, 2023

N个发送者 1一个接收者 感觉第一段select 检查提前退出这部分代码无用啊,不知道是不是我理解有问题

Copy link

ZGY1999 commented Feb 15, 2023

N个发送者 多个接收者代码部分 我个人感觉非缓存的媒介通道也可以实现这个效果啊

@KawhiZhuuu
Copy link

N个发送者 1一个接收者 感觉第一段select 检查提前退出这部分代码无用啊,不知道是不是我理解有问题

作者这里没提及一个select的重点,select当多个case可以执行时,并不是像其他语言一样,选择代码中相对靠上的case执行,而是随机执行,所以,如果没有第一段的select,第二段的select可能在极端情况下,始终执行业务channel的case,导致协程无法退出

Copy link

现在的话,是否可以用context来替代

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants