GithubHelp home page GithubHelp logo

libuv_cpp11's Introduction

libuv_cpp11


对libuv的C++风格封装,用于线上项目,做过压测。

  • TCP相关类封装:TcpServerTcpClientTcpConnectionTcpAccept。及把C风格回调改为C++11风格的回调(支持非静态类成员函数及lambda)。
  • TimerTimerWheel:定时器及时间复杂度为O(1)的心跳超时踢出机制。
  • Async:异步机制封装,由于libuv的所有api非线程安全,建议使用writeInLoop接口代替直接write(writeInLoop会检查当前调用的线程,如果在loop线程中调用则直接write,否则把write加到loop线程中执行)。
  • libuv信号封装。
  • PacketPacketBuffer:包与缓存,发送/接受包,用于解决TCP残包/粘包问题,由ListBuffer和CycleBuffer两种实现,可用宏配置(前者空间友好,后者时间友好)。
  • Log日志输出接口,可绑定至自定义Log库。

简单性能测试:单线程1k字节ping-pong。
环境:ubuntu14.04.5 + gcc5.4.1 + libuv1.13.1 + O2优化

  libuv_cpp  no use PacketBuffer CycleBuffer ListBuffer
次/秒     176817 132553 11895

!对于诸如uv::Timer,uv::TcpClient等对象的释放需要调用close接口并在回调函数中释放对象,否则可能会出错。
一点微小的工作。

libuv_cpp11's People

Contributors

wlgq2 avatar

Stargazers

 avatar

Watchers

 avatar

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.