Code Monkey home page Code Monkey logo

Comments (3)

chentmin avatar chentmin commented on September 18, 2024

本来就要在写入的时候把要发送的字节数copy到rewriter以备之后重发, 不如就在写入的线程里, 只把要写的字节数刷到rewriter里, 然后通知负责flush的线程有数据要发送. flush线程负责从上次刷成功的index开始, 写入剩余未写入的部分. 这样子修改的好处是

  • 合并多个小write
  • 写线程单线程
  • 逻辑简单, 写线程只负责把rewriter里的未发送成功的数据发出去, 重连成功和正常情况是一样的代码. 断线重连就真的只需要断开旧连接, 发起新连接的时候重置上次发送成功的index就可以.

需要额外处理发送得很慢的情况, 逻辑线程要写数据时, 未发送的数据数量超过了rewriter的大小. 可以考虑

  • 超过了就直接断线, 有64k(根据配置)的数据没有发成功, 本来就表示这连接有问题
  • 也可以临时增加rewriter的大小, 让逻辑线程可以把数据刷进去先返回. rewriter大小达到另一个配置的未发送消息的上限后, 断线

from snet.

patricksuo avatar patricksuo commented on September 18, 2024

@chentmin 请问你们有修复这个问题吗?

from snet.

chentmin avatar chentmin commented on September 18, 2024

木有, 偶c#不溜

from snet.

Related Issues (6)

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.