1 Star 4 Fork 1

LevanLiu / ThreadPool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Zlib

ThreadPool

https://gitee.com/TristanHNU/thread-pool.git

介绍

基于 C++ 17 的线程池

linux

sudo apt install build-essential gdb cmake git curl

windows

1、open shell to install chocolatey (need proxy

$Env:http_proxy="http://127.0.0.1:7890"
$Env:https_proxy="http://127.0.0.1:7890"

)

在powershell中安装chocolatey (https://community.chocolatey.org/packages/cmake.install)

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

choco install mingw --installargs 'ADD_MINGW_TO_PATH=System'
choco install cmake.install
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'

example

    // Create a thread pool with 4 worker threads
    ThreadPool pool(4);

    // Enqueue some tasks
    std::vector<std::future<int>> results;
    for (int i = 0; i < 50; i++)
    {
        results.emplace_back(
            pool.enqueue([i]
                         {
                std::cout << "Hello from task " << i << std::endl;
                std::this_thread::sleep_for(std::chrono::seconds(1));
                std::cout << "Task " << i << " completed" << std::endl;
                return i * i; }));
    }

    // Wait for all tasks to complete
    for (auto &result : results)
        std::cout << "Task completed with result: " << result.get() << std::endl;

    return 0;
Copyright (c) 2012 Jakob Progsch, Václav Zeman This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution.

简介

使用C++ 17实现的线程池。 同时支持windows linux 和 macos平台 展开 收起
C++ 等 3 种语言
Zlib
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/levanliu/thread-pool.git
git@gitee.com:levanliu/thread-pool.git
levanliu
thread-pool
ThreadPool
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891