Skip to content

huxint/ThreadPool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThreadPool

简易的 C++23 线程池,支持可组合的特性掩码。

特性

  • op::none - 基础线程池
  • op::priority - 任务��先级(low/normal/high)
  • op::cancellable - 可取消任务

特性可自由组合:ThreadPool<op::priority | op::cancellable>

用法

#include <huxint/thread_pool.hpp>

// 基础用法
ThreadPool<> pool;
auto future = pool.submit([] { return 42; });

// 带优先级
ThreadPool<op::priority> pool;
pool.submit(priority_t::high, [] { /* 高优先级任务 */ });

// 可取消任务
ThreadPool<op::cancellable> pool;
auto task = pool.submit([](token_ref token) {
    while (!token.cancelled()) {
        // 工作...
    }
});
task.cancel();  // 请求取消

构建

cmake -B build
cmake --build build

要求

  • C++23
  • CMake 3.14+

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors