{"id":13436537,"url":"https://github.com/ChunelFeng/CThreadPool","last_synced_at":"2025-03-18T21:30:37.629Z","repository":{"id":93725897,"uuid":"546101110","full_name":"ChunelFeng/CThreadPool","owner":"ChunelFeng","description":"【A simple used C++ threadpool】一个简单好用，性能优异的，跨平台的C++线程池。欢迎 star \u0026 fork","archived":false,"fork":false,"pushed_at":"2024-11-09T15:34:27.000Z","size":153,"stargazers_count":365,"open_issues_count":1,"forks_count":71,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-18T08:50:30.154Z","etag":null,"topics":["cgraph","concurrency","cpp","parallel-computing","thread","threadpool"],"latest_commit_sha":null,"homepage":"http://www.chunel.cn/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChunelFeng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-05T14:23:04.000Z","updated_at":"2025-03-10T12:15:41.000Z","dependencies_parsed_at":"2024-01-13T11:55:45.176Z","dependency_job_id":"f6468bad-c110-4de8-ac3e-39e33bb61edc","html_url":"https://github.com/ChunelFeng/CThreadPool","commit_stats":{"total_commits":18,"total_committers":4,"mean_commits":4.5,"dds":0.2222222222222222,"last_synced_commit":"8ebf49d1d889b0a8f5a8493a8847665991114d61"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChunelFeng%2FCThreadPool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChunelFeng%2FCThreadPool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChunelFeng%2FCThreadPool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChunelFeng%2FCThreadPool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChunelFeng","download_url":"https://codeload.github.com/ChunelFeng/CThreadPool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244310349,"owners_count":20432522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgraph","concurrency","cpp","parallel-computing","thread","threadpool"],"created_at":"2024-07-31T03:00:49.608Z","updated_at":"2025-03-18T21:30:37.621Z","avatar_url":"https://github.com/ChunelFeng.png","language":"C++","readme":"\u003cp align=\"left\"\u003e\n  \u003ca href=\"https://github.com/ChunelFeng/CThreadPool\"\u003e\u003cimg src=\"https://badgen.net/badge/langs/C++/cyan?list=1\" alt=\"languages\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/ChunelFeng/CThreadPool\"\u003e\u003cimg src=\"https://badgen.net/badge/os/MacOS,Linux,Windows/cyan?list=1\" alt=\"os\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/ChunelFeng/CThreadPool/stargazers\"\u003e\u003cimg src=\"https://badgen.net/github/stars/ChunelFeng/CThreadPool?color=cyan\" alt=\"stars\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/ChunelFeng/CThreadPool/network/members\"\u003e\u003cimg src=\"https://badgen.net/github/forks/ChunelFeng/CThreadPool?color=cyan\" alt=\"forks\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003e\n  CThreadPool 说明文档\n\u003c/h1\u003e\n\n## 一. 简介\n`CThreadPool` 是一个跨平台的、无任何三方依赖的、高性能的C++11（含以上版本）版本的线程池，也是 [CGraph](https://github.com/ChunelFeng/CGraph) 项目中使用的跨平台线程池组件功能的最小集。\n\n经过CGraph和关联项目的长期迭代和验证，功能已经趋于稳定，且性能优异。因为咨询相关内容的朋友较多，故做为独立的仓库提供出来，方便大家使用。\n\n由于是CGraph项目中的剥离出来的功能类，故在项目中保留了多处 `CGRAPH_*` 的命名方式，仅将 namespace 修改为 `CTP`，预计今后与CGraph相互独立更新。\n\n本项目参考了[《C++并发编程实战（第二版）》](https://nj.gitbooks.io/c/content/) 中的部分内容，和github上的一些优秀实现。并在此基础上进行大量的改动、扩展和优化，在功能、性能和易用性上均有较大的提升。\n\n在开发过程中，也沉淀了详细的说明文档（见下方 \u003cb\u003e推荐阅读\u003c/b\u003e），以便于大家快速了解代码和思路，也请大家不吝指教。\n\n## 二. 编译说明\n* 本工程支持MacOS、Linux和Windows系统，无任何第三方依赖。推荐使用C++11（默认）或以上版本，不支持以下C++11以下版本\n\n* 使用`CLion`或使用`Visual Studio 15`(或以上版本)作为IDE的开发者，打开`CMakeLists.txt`文件作为工程，即可编译通过\n\n* Linux环境开发者，在命令行模式下，输入以下指令，即可编译通过\n```shell\n$ git clone https://github.com/ChunelFeng/CThreadPool.git\n$ cd CThreadPool\n$ cmake . -Bbuild\n$ cd build\n$ make -j8\n```\n\n## 三. 使用Demo\n```cpp\n#include \"src/CThreadPool.h\"\n\nusing namespace CTP;\n\nfloat add_by_5(float i) {\n    return i + 5.0f;\n}\n\nint main() {\n    UThreadPool tp;\n    int i = 6, j = 3;\n    auto r1 = tp.commit([i, j] { return i - j; });\n    std::future\u003cfloat\u003e r2 = tp.commit(std::bind(add_by_5, 8.5f));\n\n    std::cout \u003c\u003c r1.get() \u003c\u003c std::endl;\n    std::cout \u003c\u003c r2.get() \u003c\u003c std::endl;\n    return 0;\n}\n```\n更多使用方法，请参考 `tutorial.cpp` 中的例子和文档中的内容。\n\n## 四. 推荐阅读\n* [纯序员给你介绍图化框架的简单实现——线程池优化（一）](http://www.chunel.cn/archives/cgraph-threadpool-1-introduce)\n* [纯序员给你介绍图化框架的简单实现——线程池优化（二）](http://www.chunel.cn/archives/cgraph-threadpool-2-introduce)\n* [纯序员给你介绍图化框架的简单实现——线程池优化（三）](http://www.chunel.cn/archives/cgraph-threadpool-3-introduce)\n* [纯序员给你介绍图化框架的简单实现——线程池优化（四）](http://www.chunel.cn/archives/cgraph-threadpool-4-introduce)\n* [纯序员给你介绍图化框架的简单实现——线程池优化（五）](http://www.chunel.cn/archives/cgraph-threadpool-5-introduce)\n* [纯序员给你介绍图化框架的简单实现——线程池优化（六）](http://www.chunel.cn/archives/cgraph-threadpool-6-introduce)\n\n## 五. 关联项目\n* [CGraph : A simple C++ DAG framework](https://github.com/ChunelFeng/CGraph)\n\n------------\n#### 附录-1. 版本信息\n[2022.10.05 - v1.0.0 - Chunel]\n* 提供线程池基本功能\n* 提供对应的tutorial信息\n\n[2022.10.07 - v1.0.1 - Chunel]\n* 提供默认开启辅助线程的配置\n\n[2022.10.11 - v1.1.0 - [MirrorYuChen](https://github.com/MirrorYuChen)]\n* 提供针对C++11版本的支持\n\n[2023.03.07 - v1.2.0 - Chunel]\n* 优化windows版本功能\n\n[2023.11.09 - v1.2.1 - Chunel]\n* 更新执行策略，优化整体性能\n* 修复辅助线程唤醒延时的问题\n\n------------\n#### 附录-2. 联系方式\n* 微信： ChunelFeng\n* 邮箱： chunel@foxmail.com\n* 源码： https://github.com/ChunelFeng/CThreadPool\n* 论坛： www.chunel.cn\n\n![CGraph Author](https://github.com/ChunelFeng/CThreadPool/blob/main/doc/image/CThreadPool%20Author.jpg)\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChunelFeng%2FCThreadPool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FChunelFeng%2FCThreadPool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChunelFeng%2FCThreadPool/lists"}