<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[hehelm的博客]]></title><description><![CDATA[]]></description><link>https://blog.csdn.net/hehelm</link><language>zh-cn</language><generator>https://blog.csdn.net/</generator><copyright><![CDATA[Copyright &copy; hehelm]]></copyright><item><title><![CDATA[仿muduo库实现高并发服务器—Connection]]></title><link>https://blog.csdn.net/hehelm/article/details/163999956</link><guid>https://blog.csdn.net/hehelm/article/details/163999956</guid><author>hehelm</author><pubDate>Sun, 23 Aug 2026 17:28:33 +0800</pubDate><description><![CDATA[Connection管理一个已连接的 socket fd，及其对应的事件（通过Channel提供输入/输出缓冲区，方便数据的粘包处理。管理连接状态（连接中、已连接、半关闭、已关闭）。提供回调机制，让用户处理连接建立、消息到达、连接关闭等事件。支持非活跃连接的超时释放（通过定时器）。支持协议切换（Upgrade），可在运行时改变回调函数和上下文。保证线程安全：所有关键操作都在所属的EventLoop线程中执行。]]></description><category></category></item><item><title><![CDATA[仿muduo库实现高并发服务器—EventLoop]]></title><link>https://blog.csdn.net/hehelm/article/details/163999892</link><guid>https://blog.csdn.net/hehelm/article/details/163999892</guid><author>hehelm</author><pubDate>Sun, 23 Aug 2026 17:24:33 +0800</pubDate><description><![CDATA[的作用：

：任务类型，无参数无返回值，和之前的  本质一样。
：保存创建该  时的线程 ID，用于后续判断当前线程是否为循环所在线程。
：eventfd 描述符，用来唤醒可能阻塞在  的循环。
：包装  的 ，当 eventfd 可读时调用回调。
：事件监控器，内部封装了 epoll。
：任务队列，保存其他线程投递的函数。
：保护  的互斥锁，保证多线程安全。
：定时器模块，和  绑定。


三、任务处理相关私有函数
1. RunAllTask


先从任务队列中"交换"出所有任务，避免长时间持有锁。
然]]></description><category></category></item><item><title><![CDATA[仿muduo库实现高并发服务器—Poller类]]></title><link>https://blog.csdn.net/hehelm/article/details/163999829</link><guid>https://blog.csdn.net/hehelm/article/details/163999829</guid><author>hehelm</author><pubDate>Sun, 23 Aug 2026 17:21:09 +0800</pubDate><description><![CDATA[1024表示一次epoll_wait最多可以返回多少个就绪事件。这个值通常设置得大一些，避免事件太多导致溢出。1024 是一个比较常见的默认值。int _epfd;_epfd是返回的 epoll 实例文件描述符，所有epoll_ctl和epoll_wait都围绕它进行。_evs是一个数组，用于接收epoll_wait返回的已触发事件。因为epoll_wait需要用户提供一块内存来存放事件，这里直接使用成员数组，避免每次动态分配。_channels保存 fd 到Channel*的映射。]]></description><category></category></item><item><title><![CDATA[仿muduo库实现高并发服务器—Channel类]]></title><link>https://blog.csdn.net/hehelm/article/details/163999794</link><guid>https://blog.csdn.net/hehelm/article/details/163999794</guid><author>hehelm</author><pubDate>Sun, 23 Aug 2026 17:16:51 +0800</pubDate><description><![CDATA[是一个"兜底"回调，无论发生什么事件都会调用。它可以在事件处理后做一些统一的清理或日志工作。]]></description><category></category></item><item><title><![CDATA[仿muduo库实现高并发服务器—Socket封装]]></title><link>https://blog.csdn.net/hehelm/article/details/163999721</link><guid>https://blog.csdn.net/hehelm/article/details/163999721</guid><author>hehelm</author><pubDate>Sun, 23 Aug 2026 17:14:18 +0800</pubDate><description><![CDATA[1024MAX_LISTEN是监听队列的最大长度，也就是listen()的第二个参数backlog。1024 表示内核为这个监听 socket 维护的已完成连接队列和未完成连接队列之和的最大值。简单说就是：最多允许有多少个客户端同时等待被accept()。private :_sockfd就是保存 socket 文件描述符的成员变量。Linux 中 socket 也是一个文件，所以它用一个整数 fd 来表示。]]></description><category></category></item><item><title><![CDATA[仿muduo库实现高并发服务器—TCPServer]]></title><link>https://blog.csdn.net/hehelm/article/details/163895868</link><guid>https://blog.csdn.net/hehelm/article/details/163895868</guid><author>hehelm</author><pubDate>Wed, 19 Aug 2026 22:01:07 +0800</pubDate><description><![CDATA[阻塞IO + 多线程/多进程：每个连接一个线程，连接数上来线程极多非阻塞IO + select/poll/epoll：单线程循环等待事件，但业务处理会阻塞IO有事件来了才处理，没事就阻塞等着。整个服务器就是一个事件循环，谁有数据来了就调对应的回调函数处理。muduo 是陈硕写的 C++ 网络库，它的经典设计是主线程（mainReactor）只负责监听新连接子线程池（subReactors）负责已连接的IO处理新连接来了通过轮询（Round-Robin）分配给某个子线程。]]></description><category></category></item><item><title><![CDATA[AI大模型接入SDK—SDK设计]]></title><link>https://blog.csdn.net/hehelm/article/details/163113631</link><guid>https://blog.csdn.net/hehelm/article/details/163113631</guid><author>hehelm</author><pubDate>Wed, 22 Jul 2026 20:19:52 +0800</pubDate><description><![CDATA[维度说明角色SDK 统一入口、协调者（Facade）核心方法initModels（初始化）、（全量）、（流式）设计模式外观模式（Facade）、代理模式、模板方法模式（变体）成员组合LLMManager（模型管理）+（会话管理）+（配置缓存）初始化策略两阶段：注册 → 初始化消息发送流程添加用户消息 → 获取历史 → 调用模型 → 添加助手回复 → 更新时间戳ChatSDK 的核心价值简化外部调用：客户端只需调用一个类，无需管理多个子系统协调完整闭环：从会话管理到模型调用到结果保存，一站式处理。]]></description><category></category></item><item><title><![CDATA[AI大模型接入SDK—管理器设计]]></title><link>https://blog.csdn.net/hehelm/article/details/163053838</link><guid>https://blog.csdn.net/hehelm/article/details/163053838</guid><author>hehelm</author><pubDate>Mon, 20 Jul 2026 19:48:27 +0800</pubDate><description><![CDATA[管理器核心职责设计亮点SQLite 数据持久化参数化 SQL、线程安全、RAII会话生命周期 + 缓存双层存储、内存优先、数据恢复LLMManager模型注册与路由策略模式分发、两阶段初始化三者关系依赖实现数据持久化ChatSDK组合和LLMManager，协调会话管理与模型调用LLMManager独立管理 Provider，不依赖其他管理器协作核心：ChatSDK 是协调者，通过 SessionManager 管理状态，通过 LLMManager 调用模型，实现完整的对话闭环。]]></description><category></category></item><item><title><![CDATA[AI大模型接入SDK—LLMProvider实现]]></title><link>https://blog.csdn.net/hehelm/article/details/162999181</link><guid>https://blog.csdn.net/hehelm/article/details/162999181</guid><author>hehelm</author><pubDate>Sat, 18 Jul 2026 17:11:35 +0800</pubDate><description><![CDATA[public:// 初始化模型（纯虚函数）// 检查提供方是否可用// 获取提供方名称/描述// 发送消息——全量返回// 发送消息——流式返回protected:// 提供方是否可用// API 密钥// API 端点地址Provider模型名称API 路径协议格式认证方式OpenAI 标准OpenAI 新格式OpenAI 兼容用户指定/api/chatOllama 原生无。]]></description><category></category></item><item><title><![CDATA[AI大模型接入SDK—通用模块设计]]></title><link>https://blog.csdn.net/hehelm/article/details/162998715</link><guid>https://blog.csdn.net/hehelm/article/details/162998715</guid><author>hehelm</author><pubDate>Sat, 18 Jul 2026 16:35:01 +0800</pubDate><description><![CDATA[/fmt格式化输出跟踪日志。]]></description><category></category></item><item><title><![CDATA[AI 大模型接入 SDK —项目概述]]></title><link>https://blog.csdn.net/hehelm/article/details/162977794</link><guid>https://blog.csdn.net/hehelm/article/details/162977794</guid><author>hehelm</author><pubDate>Fri, 17 Jul 2026 22:11:38 +0800</pubDate><description><![CDATA[用户调用│▼│├──▶ SessionManager::addMessage() (保存用户消息)├──▶ SessionManager::getHistoryMessages() (获取历史)│▼│▼│▼HTTP POST ──▶ 模型 API 服务端│▼JSON 响应解析│▼返回 assistant 回复│▼SessionManager::addMessage() (保存回复)]]></description><category></category></item><item><title><![CDATA[IO 多路复用 — Reactor]]></title><link>https://blog.csdn.net/hehelm/article/details/162881825</link><guid>https://blog.csdn.net/hehelm/article/details/162881825</guid><author>hehelm</author><pubDate>Tue, 14 Jul 2026 21:06:27 +0800</pubDate><description><![CDATA[/ 读事件 + 边缘触发// 写事件 + 边缘触发EPOLLET—— 边缘触发模式之前的 epollserver 用的是水平触发（LT，默认）边缘触发只在状态变化的瞬间通知一次必须配合非阻塞 IO 使用（否则会阻塞）func_t—— 回调函数类型接受一个参数无返回值可以绑定任意函数（成员函数、普通函数、lambda）阻塞 IO (read 阻塞)↓非阻塞 IO + 轮询 (CPU 空转)↓select (1024 限制，O(N))↓。]]></description><category></category></item><item><title><![CDATA[IO 多路复用 — poll & epoll]]></title><link>https://blog.csdn.net/hehelm/article/details/162881246</link><guid>https://blog.csdn.net/hehelm/article/details/162881246</guid><author>hehelm</author><pubDate>Tue, 14 Jul 2026 20:16:41 +0800</pubDate><description><![CDATA[优点缺点没有 1024 限制（数组大小可自定义）每次调用仍需把整个数组拷进内核（O(N)）events 和 revents 分离，不需要每次重建返回后仍需遍历所有 fd 检查 revents（O(N)）事件类型更丰富连接数大时效率仍不高跨平台（POSIX 标准）poll 本质上和 select 是同一类模型都是"每次调用传入所有 fd → 内核遍历检查 → 返回全部 → 用户遍历检查"区别只是数据结构不同（位图 vs 结构体数组）时间复杂度都是 O(N)]]></description><category></category></item><item><title><![CDATA[IO 多路复用—非阻塞 IO和 select]]></title><link>https://blog.csdn.net/hehelm/article/details/162880410</link><guid>https://blog.csdn.net/hehelm/article/details/162880410</guid><author>hehelm</author><pubDate>Tue, 14 Jul 2026 18:56:17 +0800</pubDate><description><![CDATA[模式read 行为没有数据时阻塞挂起进程，等待数据到达非阻塞立即返回 -1，阻塞 IO 的示意图用户进程 内核│ ││ │ 检查 fd 是否有数据│ │ 没有 → 进程挂起（阻塞）│◄──── 等待 ─────────││ │ 数据到达 → 唤醒进程│◄── 返回数据 ───────│非阻塞 IO 的示意图用户进程 内核│ ││ │ 检查 fd 是否有数据│ │ 没有 → 直接返回 -1│◄── -1, EAGAIN ─────│ 不阻塞！│ │。]]></description><category></category></item><item><title><![CDATA[Linux网络编程—自定义协议]]></title><link>https://blog.csdn.net/hehelm/article/details/162850567</link><guid>https://blog.csdn.net/hehelm/article/details/162850567</guid><author>hehelm</author><pubDate>Mon, 13 Jul 2026 22:03:16 +0800</pubDate><description><![CDATA[报文封装/解封Encode()Decode()—— 解决 TCP 粘包问题请求类Request—— 序列化/反序列化计算请求响应类Response—— 序列化/反序列化计算结果完整的数据流转过程│"10 + 20" (或 JSON)│▼ Encode()"7\n10 + 20\n" (加了长度前缀)│▼ write() 发送到网络│▼ read() 接收端读取│▼ Decode()"10 + 20" (去掉长度前缀)│协议分层层次函数职责应用层Serialize。]]></description><category></category></item><item><title><![CDATA[Linux网络编程—HTTP静态文件服务器]]></title><link>https://blog.csdn.net/hehelm/article/details/162850425</link><guid>https://blog.csdn.net/hehelm/article/details/162850425</guid><author>hehelm</author><pubDate>Mon, 13 Jul 2026 21:51:59 +0800</pubDate><description><![CDATA[这个项目实现了一个。]]></description><category></category></item><item><title><![CDATA[Linux网络编程—TCP字典翻译系统]]></title><link>https://blog.csdn.net/hehelm/article/details/162849458</link><guid>https://blog.csdn.net/hehelm/article/details/162849458</guid><author>hehelm</author><pubDate>Mon, 13 Jul 2026 20:35:27 +0800</pubDate><description><![CDATA[UDP（无连接）：客户端 ──sendto──> 服务端（一个 Socket 收所有）TCP（面向连接）：客户端 ──connect──> 服务端 listen Socket│accept() 取出连接│返回新的 sockfd（专门服务这个客户端）UDP 不需要维护连接状态，一个 Socket 收发所有数据TCP 需要为每个客户端维护独立的连接状态（序号、窗口等），所以需要独立的 sockfd。]]></description><category></category></item><item><title><![CDATA[Linux网络编程—UDP 群聊系统]]></title><link>https://blog.csdn.net/hehelm/article/details/162848900</link><guid>https://blog.csdn.net/hehelm/article/details/162848900</guid><author>hehelm</author><pubDate>Mon, 13 Jul 2026 19:47:14 +0800</pubDate><description><![CDATA[意义：定义一个函数类型别名，把可调用对象类型简化为func_t。func_t表示一个"接收消息、客户端IP、客户端端口，返回处理后字符串"的函数。这是给将来做"业务逻辑回调"预留的接口。enumSOCKET_ERROR = 1, // socket() 失败时 exit 的状态码BIND_ERROR = 2, // bind() 失败时 exit 的状态码意义：自定义错误码。exit(非零值)表示异常退出，0 表示正常退出。不同的错误用不同的非零值，方便排查。意义：默认监听 8080 端口。]]></description><category></category></item><item><title><![CDATA[Linux 信号（Signal）]]></title><link>https://blog.csdn.net/hehelm/article/details/161364989</link><guid>https://blog.csdn.net/hehelm/article/details/161364989</guid><author>hehelm</author><pubDate>Sun, 24 May 2026 14:23:19 +0800</pubDate><description><![CDATA[产生↓pending↓block 判断↓递达↓handler。]]></description><category></category></item><item><title><![CDATA[C++ 特殊类设计]]></title><link>https://blog.csdn.net/hehelm/article/details/161119913</link><guid>https://blog.csdn.net/hehelm/article/details/161119913</guid><author>hehelm</author><pubDate>Fri, 15 May 2026 18:19:59 +0800</pubDate><description><![CDATA[private:// 只声明，不实现 + 设为私有需求核心方法不能拷贝禁拷贝构造 + 赋值重载只能在堆上构造私有 + 静态工厂返回 new只能在栈上禁 new + 静态工厂返回栈对象不能被继承final / 构造私有单例模式饿汉（启动创建）/ 懒汉（首次创建）]]></description><category></category></item></channel></rss>