网站的字体颜色,上海有名公司有哪些,订票网站开发公司,网页设计个人网站怎么做基于Arrow的轻量线程池 大家好#xff0c;我是光城#xff0c;最近花了几周业余时间#xff0c;开发出这款轻量线程池#xff0c;代码也全部开源啦#xff0c;欢迎大家star。 本线程池的设计与实现会有涉及非常多的知识#xff0c;这些内容也都会以视频的方式分享在知识星… 基于Arrow的轻量线程池 大家好我是光城最近花了几周业余时间开发出这款轻量线程池代码也全部开源啦欢迎大家star。 本线程池的设计与实现会有涉及非常多的知识这些内容也都会以视频的方式分享在知识星球中随便一罗列就是一大堆在学习本线程过程中你会学到 - 如何从0构建一个项目 - 如何使用bazel管理整个项目 - 如何设计一个属于自己的线程池 - Arrow 项目与现在的线程池区别在哪里我们做了什么改造 - 如何实战并发编程 - 如何做测试 等等。 本线程池是基于Apache Arrow项目的衍生版本。我们将Arrow项目中复杂的核心结构——线程池——完全剥离出来形成了这个独立的项目。由于原始的线程池与Arrow项目本身的工具有深度依赖关系因此我们在这个项目中对线程池进行了一些深度移除和改造以保持与原始Arrow线程池的基础功能一致。一些改动包括 将Arrow的Future替换为std::future将Arrow的Result替换为std::optional重构了Submit接口使用promise进行实现 通过这些改动我们的目标是 使线程池更方便地作为其他项目的依赖库使用提供简单的方式来引入本项目的so库和头文件以使用线程池功能 此外这个项目还可以作为深入学习线程池设计与实现的资源。我们欢迎您探索并使用这个经过精心改进的线程池。 项目地址参考下面 https://github.com/Light-City/light-thread-pool 1.如何编译 ➜ tpl bazel build //src:thread_pool
WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE.
WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE.
INFO: Analyzed target //src:thread_pool (36 packages loaded, 168 targets configured).
INFO: Found 1 target...
Target //src:thread_pool up-to-date:bazel-bin/src/libthread_pool.abazel-bin/src/libthread_pool.dylib
INFO: Elapsed time: 1.748s, Critical Path: 1.34s
INFO: 8 processes: 3 internal, 5 darwin-sandbox.
INFO: Build completed successfully, 8 total actions 2.如何使用 所有的用例放在examples目录 2.1 编写一个简单的case 参见helloworld // Create a thread pool
auto threadPool GetCpuThreadPool();
if (!threadPool) {std::cerr Failed to create thread pool std::endl;return 1;
}// Submit tasks to the thread pool
threadPool-Spawn([]() { std::cout hello world! std::endl; });// Wait for all tasks to complete
threadPool-WaitForIdle();// Shutdown the thread pool
threadPool-Shutdown(); 其他case: 设置线程池数量如何停止回调如何异步处理 3.如何测试 测试基于catch2编写所有测试位于tests目录 可以测试tests目录下面的其他测试只需要替换submit_test为对应的test即可。 bazel test //tests:submit_test