当前位置:网站首页>Libuv asynchronous task logic and UV_ queue_ work()
Libuv asynchronous task logic and UV_ queue_ work()
2022-06-22 03:02:00 【Call me Xiao Huang】
Preface
libuv No, asio Of post function , But we can uv_async_init+uv_async_send simulation ,uv_async_send Parameters can be transferred by async.data. Because some tasks are time-consuming ( Such as file reading and writing , Or connection mysql), If you add it directly to eventloop in , It will affect eventloop Throughput , therefore libuv Provides uv_queue_work To solve this situation .
libuv Asynchronous task logic
This part is actually uv_loop_run Extension of , Instead of code by code analysis, go directly to the flow chart .

uv_queue_work(loop,callback, done)
libuv Provides thread pool . In order to solve the problem that some asynchronous tasks take too long, it will affect eventloop Throughput of , We can divide this task into two parts :callback Time consuming logic ,done For the end of execution callback The follow-up logic of .callback Give it to the thread pool to complete , Add... As soon as you're done done To eventloop in , Then wake up eventloop, call uv_work_done function , call done function .
uv_queue_work Of work req Detailed flow chart for adding and callback triggers

Here I can feel more req and handle The difference between ,handle It always exists after initialization loop in , We need to call close From the loop Remove , but req You don't need to , After adding to the thread pool work queue , After one execution , It will be removed from the work queue ,done Part of the same ( from loop Of wq Remove ).
边栏推荐
- Comprehensive interpretation by enterprise reviewers: enterprise growth of [State Grid] China Power Finance Co., Ltd
- 交通标志分类
- Figure database ongdb release v-1.0.2
- Will it take three months or half a year to buy financial products in 2022?
- 关于mysql的int型主键自增问题
- Microsoft Internet Explorer was permanently closed on June 15
- Latest release: neo4j figure data science GDS 2.0 and aurads GA
- [6. high precision multiplication]
- Graphacademy course explanation: introduction to neo4j graph data science
- 【2. 归并排序】
猜你喜欢
![[3. binary integer and floating point number]](/img/82/6c3ef250b90d875cddaebc5bd4a4b8.png)
[3. binary integer and floating point number]
![[6. high precision multiplication]](/img/83/1659503e62839c395ca7849596d6fc.png)
[6. high precision multiplication]

记一则服务器内存泄漏解决过程
![[percona toolkit] series of Pt table checksum and Pt table sync data verification and repair artifacts](/img/1f/89cc2ec9ae6c967791994acac55c04.png)
[percona toolkit] series of Pt table checksum and Pt table sync data verification and repair artifacts

关于mysql的int型主键自增问题

Day16QtQLabel2021-10-22

ATM机模拟系统
![Comprehensive interpretation by enterprise reviewers: enterprise growth of [State Grid] China Power Finance Co., Ltd](/img/4e/345ceb4e91aae844d7ab53ad3fd988.png)
Comprehensive interpretation by enterprise reviewers: enterprise growth of [State Grid] China Power Finance Co., Ltd

ACL 2022 | multilingual knowledge map reasoning based on self supervised graph alignment

Use of day19qpushbutton 2021-10-30
随机推荐
Typora + picGo 配置图床实现图片自动上传
【 thesis 】 zero reference depth curve estimation for low light image enhancement
table标签的不规则布局
【1. 快速排序】
Two dot vertical progress styles
The brand, products and services are working together. What will Dongfeng Nissan do next?
【5. 高精度减法】
torch.max()使用讲解
web框架概述与程序开发
PMP reference related agile knowledge
[4. high precision addition]
【2. 归并排序】
Unity3d post process volume profile
交通标志分类
All the knowledge you want to know about the PMP Exam is here
Day13QMainWindow2021-09-28
Day14QProgressBar2021-10-17
Microsoft Internet Explorer was permanently closed on June 15
xpm_ memory_ A complete example of using the tdpram primitive
uv_run流程