chenyahui / chenyahui.github.io

My blog
http://www.cyhone.com
0 stars 2 forks source link

muduo 源码剖析 | 编程沉思录 #41

Open chenyahui opened 4 years ago

chenyahui commented 4 years ago

https://www.cyhone.com/articles/analysis-of-muduo/

muduo是 陈硕 大神个人开发的 C++ 的 TCP 网络编程库。muduo 基于 Reactor 模式实现。Reactor 模式也是目前大多数 Linux 端高性能网络编程框架和网络应用所选择的主要架构,例如内存数据库 Redis 和 Java 的 Netty 库等。 陈硕的《Linux 多线程服务器端编程》一书对 muduo 整个架构进行了非常详尽的介绍和分析,可以说是学习 muduo 源码

shawnjyang commented 2 years ago

你好,请问一下博主,在您讲到 callingPendingFunctors_ 的作用里,说“如果调用 queueInLoop 和 EventLoop 在同一个线程,且 callingPendingFunctors为 false 时,则说明:此时尚未执行到 doPendingFunctors()。那么此时即使不用 wakeup,也可以在之后照旧执行 doPendingFunctors() 了”,我有点没太理解,我想的是即使没有 callingPendingFunctors ,此时也不会进入 if 唤醒 EventLoop 呀,麻烦博主能解释一下嘛?

chenyahui commented 2 years ago

@shawnjyang 你好,请问一下博主,在您讲到 callingPendingFunctors_ 的作用里,说“如果调用 queueInLoop 和 EventLoop 在同一个线程,且 callingPendingFunctors为 false 时,则说明:此时尚未执行到 doPendingFunctors()。那么此时即使不用 wakeup,也可以在之后照旧执行 doPendingFunctors() 了”,我有点没太理解,我想的是即使没有 callingPendingFunctors ,此时也不会进入 if 唤醒 EventLoop 呀,麻烦博主能解释一下嘛?

如果用户没有调用runInLoop而是调了 queueInLoop,这个时候callingPendingFunctors_就会起到作用

shawnjyang commented 2 years ago

@chenyahui

@shawnjyang 你好,请问一下博主,在您讲到 callingPendingFunctors_ 的作用里,说“如果调用 queueInLoop 和 EventLoop 在同一个线程,且 callingPendingFunctors为 false 时,则说明:此时尚未执行到 doPendingFunctors()。那么此时即使不用 wakeup,也可以在之后照旧执行 doPendingFunctors() 了”,我有点没太理解,我想的是即使没有 callingPendingFunctors ,此时也不会进入 if 唤醒 EventLoop 呀,麻烦博主能解释一下嘛?

如果用户没有调用runInLoop而是调了 queueInLoop,这个时候callingPendingFunctors_就会起到作用

好的,谢谢噢!!

pengdahong1225 commented 1 week ago

优秀