Coder Social home page Coder Social logo

Comments (2)

haozibi avatar haozibi commented on May 18, 2024 1

@TapirLiu 非常感谢解答,而且我注意到线上图书已经更新了,辛苦了。

from golang101.

dotaheor avatar dotaheor commented on May 18, 2024

对于第一个,如果不为缓冲通道的话,则两个未被选择的case对应的协程将处于永久阻塞状态,造成内存泄露。

对于第二个,缓冲为0的情况其实也可以,具体取决于具体应用的要求。缓冲为0时,(站在接收者的角度),每两个连续接收操作的间隔肯定大于d;而缓冲为1时,(站在发送者的角度),尽量保证在每个Nd时刻发送一个信号。其实缓冲大于1也不是一点道理没有,但是容易造成瞬时发生很多接受操作的情况。

这里缓冲取1是为了和标准库包中的time.Tick函数的行为保持一致。

不过一些描述确实需要再调整一下。多谢提出这个问题。

from golang101.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.