TCP design based on LIBUV (iii)

Source: Internet
Author: User

?

based on LIBUV of the TCP Design (i)

based on LIBUV of the TCP Design (ii)

?

first, the second version of the libuv_tcp is already basic to use. No error and crashes, support hundreds of-way client connection simultaneously. However, there is a flaw that consumes Very high CPU. Because the idle phase detects that there is no data to send, idle idling when the server is idle , consumes CPU. Improvements have been made to this process today.

?

?

Second, improve

1. Remove the prepare,check,idle Event

2.prepare in the judge user off TCP and send data by Uv_async_send Replace

3. redefining the client data struct and the struct that sent the data

4. when the idle handle,write_t is collected, it is estimated that more than expected, long time does not recover, direct release.

5.Packet class is changed to Packetsync . Resolve the database package synchronously, enough to trigger a callback directly to the user. No longer uses another thread to resolve asynchronously.

?

——————————————————————————————————————————————————————————————————————

The code has been uploaded to git:? https://github.com/wqvbjhc/libuv_tcp

?

?

本文版权归作者和博客园共有,来源网址:http://www.cnblogs.com/wqvbjhc/

欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接,否则保留追究法律责任的权利。

?

?

TCP design based on LIBUV (iii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.