Git Product home page Git Product logo

binary's People

Contributors

bg5sbk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binary's Issues

BufferPool的设计问题

我觉得现在这个内存池设计得不好,以link里的codec_packet.go为例,里面的EncoderDecoder会尽量复用[]byte,只有在序列化消息容量不够或者是接收包的时候容量不够时才会make一个新的,所以[]byte的创建频率是不高的。

现在的BufferPool比较符合的应用场景是频繁的创建销毁[]byte的场景,跟上面这种应用场景不符,如果长久持有[]byte,BufferPool里面的[]byte很快就被耗尽了并且不会被回收利用。

所以codec_packet.go里面用sync.Pool更合适,在频繁创建销毁[]byte的时候sync.Pool会尽量重用对象,在频率低的时候对象又会被释放。

对于sync.Pool不能精确分类[]byte的问题,可以用多个sync.Pool来实现。

writer.go的bug

func (writer *Writer) Flush() error {
    if flusher, ok := writer.w.(FlushWriter); writer.err != nil && ok {
        writer.err = flusher.Flush()
    }
    return writer.err
}

上面的代码是不是应该修改为

func (writer *Writer) Flush() error {
    if flusher, ok := writer.w.(FlushWriter); writer.err == nil && ok {
        writer.err = flusher.Flush()
    }
    return writer.err
}

我是新手,如果提错了,请谅解

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.