Code Monkey home page Code Monkey logo

Comments (4)

liutaihua avatar liutaihua commented on June 1, 2024

https://zh.wikipedia.org/wiki/%E7%92%B0%E5%BD%A2%E7%B7%A9%E8%A1%9D%E5%8D%80

在这里,我想一方面可以复用对象, 另外一方面心跳的一来一回正好和它的两个指针(write 和read)很像. 另外数组的实现比链表对CPU更友好

from goim.

Terry-Mao avatar Terry-Mao commented on June 1, 2024

无锁的一个ring 复用数据结构用的;

from goim.

molon avatar molon commented on June 1, 2024

@Terry-Mao 关于这个请教一个可能比较业余的问题。这里面的wp和rp都一定能保证原子性么?否则的话为什么就能保证线程安全呢。

另外有看到例如缓冲池的大小设置为5,如果消费能力很差的情况下,客户端连接就会断开,这个是出于什么目的呢?

from goim.

Terry-Mao avatar Terry-Mao commented on June 1, 2024

能保证原子,取决于CPU 平台,64的话,确实是原子,但是 不一定goroutine 可见,这个是一个问题,可以用atomic来处理,目前相对比较少遇到这种问题(不可见),不过确实不安全

缓冲池,根据业务可以调整;

from goim.

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.