golang中虽然有带缓冲的channel,但是并没有无限缓冲的channl,本文整理汇总当前一些实现方式
文章目录
- [Building an Unbounded Channel in Go](https://medium.com/capital-one-tech/building-an-unbounded-channel-in-go-789e175cd2cd)
- [Unbounded Queue: A tale of premature optimization](www.golangdevops.com/2017/12/29/unbounded-queue/)
- [proposal: spec: add support for unlimited capacity channels](https://github.com/golang/go/issues/20352)
Building an Unbounded Channel in Go
通过增加一个中间goroute的方式,实现了无限缓冲的channle
具体实现代码:
代码对应的测试用用例
作者在实现的时候,先写测试用例,然后再实现代码的方式值得借鉴。
Unbounded Queue: A tale of premature optimization
通过更改接口实现 unbounded.go
proposal: spec: add support for unlimited capacity channels
在golang的官网其实有人提出过这个提议,但是并没有被官方接受。