<feed xmlns="http://www.w3.org/2005/Atom"> <id>https://desyang-hub.github.io/</id><title>desyang</title><subtitle>A minimal, responsive and feature-rich Jekyll theme for technical writing.</subtitle> <updated>2026-06-04T11:06:59+08:00</updated> <author> <name>desyang</name> <uri>https://desyang-hub.github.io/</uri> </author><link rel="self" type="application/atom+xml" href="https://desyang-hub.github.io/feed.xml"/><link rel="alternate" type="text/html" hreflang="zh-CN" href="https://desyang-hub.github.io/"/> <generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator> <rights> © 2026 desyang </rights> <icon>/assets/img/favicons/favicon.ico</icon> <logo>/assets/img/favicons/favicon-96x96.png</logo> <entry><title>C++ 智能指针实战：用 weak_ptr 破解 shared_ptr 循环引用导致的内存泄漏</title><link href="https://desyang-hub.github.io/posts/C++%E6%99%BA%E8%83%BD%E6%8C%87%E9%92%88weak_ptr%E5%AE%9E%E6%88%98/" rel="alternate" type="text/html" title="C++ 智能指针实战：用 weak_ptr 破解 shared_ptr 循环引用导致的内存泄漏" /><published>2026-06-04T11:01:00+08:00</published> <updated>2026-06-04T11:01:00+08:00</updated> <id>https://desyang-hub.github.io/posts/C++%E6%99%BA%E8%83%BD%E6%8C%87%E9%92%88weak_ptr%E5%AE%9E%E6%88%98/</id> <content type="text/html" src="https://desyang-hub.github.io/posts/C++%E6%99%BA%E8%83%BD%E6%8C%87%E9%92%88weak_ptr%E5%AE%9E%E6%88%98/" /> <author> <name>desyang</name> </author> <category term="C++" /> <category term="智能指针" /> <summary>在开发一个基于 Reactor 模式的 C++ 网络库时，我遇到了一个经典的内存管理难题：对象无法被析构，导致文件描述符（fd）泄露和内存持续增长。经过一番调试，最终发现罪魁祸首是 std::shared_ptr 的循环引用，而解决方案正是 C++11 引入的另一个智能指针——std::weak_ptr。 今天，我想和大家分享这次踩坑与填坑的完整过程，希望能帮助正在学习或使用 C++ 智能指针的朋友们。 项目背景 我的网络库核心组件包括： EventLoop: 事件循环。 Channel: 封装一个文件描述符（fd）及其关注的事件（读/写）。 Connection: 管理一个 TCP 连接，持有 Socket 和 Channel 对象，并包含一个读缓冲区 Buffer。 为了简化对象生命周期管理，我决定使用 std::shared_ptr 来管理 Connec...</summary> </entry> <entry><title>unique_ptr自定义删除器</title><link href="https://desyang-hub.github.io/posts/unique_ptr%E8%87%AA%E5%AE%9A%E4%B9%89%E5%88%A0%E9%99%A4%E5%99%A8/" rel="alternate" type="text/html" title="unique_ptr自定义删除器" /><published>2026-04-26T11:38:00+08:00</published> <updated>2026-04-26T11:38:00+08:00</updated> <id>https://desyang-hub.github.io/posts/unique_ptr%E8%87%AA%E5%AE%9A%E4%B9%89%E5%88%A0%E9%99%A4%E5%99%A8/</id> <content type="text/html" src="https://desyang-hub.github.io/posts/unique_ptr%E8%87%AA%E5%AE%9A%E4%B9%89%E5%88%A0%E9%99%A4%E5%99%A8/" /> <author> <name>desyang</name> </author> <category term="cpp" /> <category term="智能指针" /> <summary>unique_ptr 自定义删除器：从入门到精通 在 C++11 引入的智能指针中，std::unique_ptr 因其高效的性能（零开销抽象）和明确的独占所有权语义而备受推崇。默认情况下，unique_ptr 会使用 delete 运算符来释放资源。然而，在实际开发中，我们管理的资源往往不仅仅是堆内存，还可能是文件句柄、网络连接、数据库连接或操作系统特定的句柄。这时，默认的 delete 就不再适用了，我们需要为 unique_ptr 定义自定义删除器。 为什么需要自定义删除器？ 标准库的 delete 只能释放通过 new 分配的内存。如果你尝试对以下资源使用默认删除器，会导致未定义行为或资源泄漏： 文件指针：需要调用 fclose。 动态数组：需要调用 delete[]。 Windows 句柄：需要调用 CloseHandle。 SQLite 数据库连...</summary> </entry> <entry><title>C++设计模式实战：掌握最核心的7种设计模式"</title><link href="https://desyang-hub.github.io/posts/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/" rel="alternate" type="text/html" title="C++设计模式实战：掌握最核心的7种设计模式&amp;quot;" /><published>2026-03-12T18:58:00+08:00</published> <updated>2026-03-12T14:54:10+08:00</updated> <id>https://desyang-hub.github.io/posts/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/</id> <content type="text/html" src="https://desyang-hub.github.io/posts/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/" /> <author> <name>desyang</name> </author> <category term="cpp" /> <category term="设计模式" /> <summary>在软件工程中，虽然《设计模式》（GoF）一书列出了23种模式，但在实际开发中，最常用、最核心的通常只有7-8种。 掌握这几种模式，能解决80%以上的常见架构问题。本文将介绍一个C++设计模式实战项目，帮助你深入理解这些核心设计模式。 项目链接：design-patterns-cpp 项目简介 这是一个专注于C++设计模式实现的项目，包含了最常用的设计模式的实际代码示例。每个模式都配有完整的实现代码和测试用例，帮助开发者理解设计模式的实际应用。 核心设计模式 项目将设计模式分为三类，按使用频率和重要性排序： 🏆 第一梯队：必须掌握（出现频率最高） 1. 单例模式 (Singleton) - [创建型] 一句话解释：保证一个类只有一个实例，并提供全局访问点。 应用场景： 数据库连接池、线程池 日志记录器 (Logger) 配置管理器 (Config Ma...</summary> </entry> <entry><title>C++ 并发编程实战：手写一个简易线程池 (ThreadPool)</title><link href="https://desyang-hub.github.io/posts/%E6%89%8B%E5%86%99%E4%B8%80%E4%B8%AA%E7%AE%80%E6%98%93%E7%BA%BF%E7%A8%8B%E6%B1%A0/" rel="alternate" type="text/html" title="C++ 并发编程实战：手写一个简易线程池 (ThreadPool)" /><published>2026-02-27T15:30:00+08:00</published> <updated>2026-04-28T13:10:37+08:00</updated> <id>https://desyang-hub.github.io/posts/%E6%89%8B%E5%86%99%E4%B8%80%E4%B8%AA%E7%AE%80%E6%98%93%E7%BA%BF%E7%A8%8B%E6%B1%A0/</id> <content type="text/html" src="https://desyang-hub.github.io/posts/%E6%89%8B%E5%86%99%E4%B8%80%E4%B8%AA%E7%AE%80%E6%98%93%E7%BA%BF%E7%A8%8B%E6%B1%A0/" /> <author> <name>desyang</name> </author> <category term="cpp" /> <category term="thread-pool" /> <summary>深入解析 C++11 线程池的实现原理，通过代码实战讲解 std::thread, std::mutex, std::condition_variable 的协同工作机制，以及如何优雅地管理任务队列和线程生命周期。</summary> </entry> <entry><title>解决校园网下 Git Push 失败：从 SSH 被拒到 HTTPS 证书信任的完整实践</title><link href="https://desyang-hub.github.io/posts/%E4%BD%BF%E7%94%A8Stream++%E4%BB%A3%E7%90%86%E6%97%A0%E6%B3%95clone%E5%92%8Cpush/" rel="alternate" type="text/html" title="解决校园网下 Git Push 失败：从 SSH 被拒到 HTTPS 证书信任的完整实践" /><published>2026-02-26T09:15:00+08:00</published> <updated>2026-02-27T15:44:12+08:00</updated> <id>https://desyang-hub.github.io/posts/%E4%BD%BF%E7%94%A8Stream++%E4%BB%A3%E7%90%86%E6%97%A0%E6%B3%95clone%E5%92%8Cpush/</id> <content type="text/html" src="https://desyang-hub.github.io/posts/%E4%BD%BF%E7%94%A8Stream++%E4%BB%A3%E7%90%86%E6%97%A0%E6%B3%95clone%E5%92%8Cpush/" /> <author> <name>desyang</name> </author> <category term="stream++" /> <category term="Git" /> <summary>背景：被校园网“劝退”的 GitHub 之旅 作为一名开发者，长期以来受限于校园网的网络环境，我在访问 GitHub 时常常遇到连接超时、克隆失败等问题。为了规避这些麻烦，我不得不将许多项目托管在 Gitee（码云）上。虽然 Gitee 在国内速度飞快，但失去了 GitHub 庞大的开源生态和国际交流机会，始终是一种遗憾。 最近，我尝试重新将工作流迁移回 GitHub，却在第一步就遭遇了“滑铁卢”。本文将详细记录我如何排查问题，并从 SSH 协议 成功切换到 HTTPS 协议，并通过配置 Git 信任 Watt Toolkit (原 Steam++) 的本地证书，实现了既安全又丝滑的 git push 体验。 遇到的问题 1. SSH 协议直接被拒 起初，我习惯性地使用 SSH 协议进行克隆操作： git clone git@github.com:desyang-hub/d...</summary> </entry> </feed>
