@@ -5,6 +5,7 @@ An easy-to-use and efficient C++ 20 thread pool that supports task priorities an
55[ ![ License] ( https://img.shields.io/badge/License-MIT%20OR%20Apache--2.0-blue.svg )] ( LICENSE )
66![ Require] ( https://img.shields.io/badge/%20Require%20-%3E=%20C++%2020-orange.svg )
77[ ![ CMake] ( https://img.shields.io/badge/CMake-3.14+-green.svg )] ( https://cmake.org/ )
8+ ![ Module Support] ( https://img.shields.io/badge/Modules-C%2B%2B20-blueviolet.svg )
89
910## Features
1011
@@ -21,7 +22,7 @@ An easy-to-use and efficient C++ 20 thread pool that supports task priorities an
2122
2223## Quick Start
2324
24- Configuration: [ CMake] ( #cmake ) | [ Manual] ( #manual ) | [ Test] ( #test )
25+ Configuration: [ CMake] ( #cmake ) | [ vcpkg ] ( #vcpkg ) | [ Conan ] ( #conan ) | [ Manual] ( #manual ) | [ Test] ( #test )
2526
2627Example: [ Basic Usage] ( #basic-usage ) | [ Tasks with Parameters] ( #tasks-with-parameters ) | [ Set Maximum Queue Size] ( #set-maximum-queue-size ) | [ Dynamic Thread Count Adjustment] ( #dynamic-thread-count-adjustment ) | [ Error Handling] ( #error-handling )
2728
@@ -54,81 +55,172 @@ target_link_libraries(your_target PRIVATE Neko::ThreadPool)
5455#include < neko/thread/threadPool.hpp>
5556```
5657
57- ### Manual
58+ #### CMake with Module Support
5859
59- When installing manually, you need to manually fetch the dependency [ ` NekoSchema ` ] ( https://github.com/moehoshio/NekoSchema ) .
60+ To enable C++20 module support, use the ` NEKO_THREAD_POOL_ENABLE_MODULE ` option:
6061
61- After installing the dependency, please continue:
62+ ``` cmake
63+ FetchContent_Declare(
64+ ...
65+ )
6266
63- 1 . Clone or download the repository to your host
67+ # Set Options Before Building
68+ set(NEKO_THREAD_POOL_ENABLE_MODULE ON CACHE BOOL "" FORCE)
69+ FetchContent_MakeAvailable(NekoThreadPool)
6470
65- ``` sh
66- git clone https://github.com/moehoshio/NekoThreadPool.git
71+ ...
72+
73+ target_link_libraries(your_target PRIVATE Neko::ThreadPool::Module)
6774```
6875
69- or
76+ Import the module in your source code:
7077
71- ``` sh
72- curl -L -o NekoThreadPool.zip https://github.com/moehoshio/NekoThreadPool/archive/refs/heads/main.zip
78+ ``` cpp
79+ import neko.thread;
80+ ```
7381
74- unzip NekoThreadPool.zip
82+ ### vcpkg
83+
84+ Install NekoThreadPool using vcpkg:
85+
86+ ``` shell
87+ vcpkg install neko-threadpool
7588```
7689
77- 2 . Copy the contents of the ` NekoThreadPool/include ` folder into your project's ` include ` directory.
90+ Or add it to your ` vcpkg.json ` :
91+
92+ ``` json
93+ {
94+ "dependencies" : [" neko-threadpool" ]
95+ }
96+ ```
97+
98+ Then in your CMakeLists.txt:
99+
100+ ``` cmake
101+ find_package(NekoThreadPool CONFIG REQUIRED)
102+ target_link_libraries(your_target PRIVATE Neko::ThreadPool)
103+ ```
104+
105+ When configuring your project, specify the vcpkg toolchain file:
78106
79107``` shell
80- cp -r NekoThreadPool/include/ /path/to/your/include/
108+ cmake -B build -DCMAKE_PREFIX_PATH=/path/to/vcpkg/installed/x64-windows
109+ cmake --build build --config Debug
81110```
82111
83- 3 . Include the header in your source code
112+ Note: Installing via vcpkg does not support modules.
84113
85- ``` cpp
86- #include < neko/core/threadPool.hpp>
114+ ### Conan
115+
116+ Add NekoThreadPool to your ` conanfile.txt ` :
117+
118+ ``` ini
119+ [requires]
120+ neko-threadpool/*
121+
122+ [generators]
123+ CMakeDeps
124+ CMakeToolchain
87125```
88126
89- ### C++20 Module Support
127+ Or use it in your ` conanfile.py ` :
90128
91- NekoThreadPool supports C++20 modules
129+ ``` python
130+ from conan import ConanFile
92131
93- #### Building with Module Support
132+ class YourProject (ConanFile ):
133+ requires = " neko-threadpool/*"
134+ generators = " CMakeDeps" , " CMakeToolchain"
135+ ```
94136
95- To enable C++20 module support, use the ` NEKO_THREAD_POOL_ENABLE_MODULE ` option:
137+ Then install and use:
138+
139+ ``` shell
140+ conan install . --build=missing
141+ cmake -B build -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake
142+ cmake --build build
143+ ```
144+
145+ In your CMakeLists.txt:
96146
97147``` cmake
98- include(FetchContent)
148+ find_package(NekoThreadPool CONFIG REQUIRED)
149+ target_link_libraries(your_target PRIVATE Neko::ThreadPool)
150+ ```
99151
100- FetchContent_Declare(
101- NekoSchema
102- GIT_REPOSITORY https://github.com/moehoshio/NekoSchema.git
103- GIT_TAG main
104- )
152+ #### Conan with C++20 Module Support
105153
106- # Enable module support
107- set(NEKO_THREAD_POOL_ENABLE_MODULE ON CACHE BOOL "" FORCE)
154+ To enable C++20 module support with Conan, use the ` enable_module ` option:
108155
109- FetchContent_MakeAvailable(NekoSchema)
156+ ``` shell
157+ conan install . --build=missing -o neko-threadpool/* :enable_module=True
158+ ```
110159
111- # Link against the module target
112- add_executable(your_target main.cpp)
160+ Or specify it in your ` conanfile.txt ` :
161+
162+ ``` ini
163+ [requires]
164+ neko-threadpool/*
165+
166+ [options]
167+ neko-threadpool/*:enable_module =True
168+
169+ [generators]
170+ CMakeDeps
171+ CMakeToolchain
172+ ```
173+
174+ Or in your ` conanfile.py ` :
175+
176+ ``` python
177+ from conan import ConanFile
178+
179+ class YourProject (ConanFile ):
180+ requires = " neko-threadpool/*"
181+ generators = " CMakeDeps" , " CMakeToolchain"
182+
183+ def configure (self ):
184+ self .options[" neko-threadpool" ].enable_module = True
185+ ```
186+
187+ Then link against the module target in your CMakeLists.txt:
188+
189+ ``` cmake
190+ find_package(NekoThreadPool CONFIG REQUIRED)
113191target_link_libraries(your_target PRIVATE Neko::ThreadPool::Module)
114192```
115193
116- #### Using the Module
194+ ### Manual
117195
118- Instead of including headers, simply import the module:
196+ When installing manually, you need to manually fetch the dependency [ ` NekoSchema ` ] ( https://github.com/moehoshio/NekoSchema ) .
119197
120- ``` cpp
121- #include < iostream>
122- import neko.thread;
198+ After installing the dependency, please continue:
123199
124- int main () {
125- neko::thread::ThreadPool pool;
126- auto future = pool.submit([]() {
127- return 42;
128- });
129- std::cout << "Result: " << future.get() << std::endl;
130- return 0;
131- }
200+ 1 . Clone or download the repository to your host
201+
202+ ``` sh
203+ git clone https://github.com/moehoshio/NekoThreadPool.git
204+ ```
205+
206+ or
207+
208+ ``` sh
209+ curl -L -o NekoThreadPool.zip https://github.com/moehoshio/NekoThreadPool/archive/refs/heads/main.zip
210+
211+ unzip NekoThreadPool.zip
212+ ```
213+
214+ 2 . Copy the contents of the ` NekoThreadPool/include ` folder into your project's ` include ` directory.
215+
216+ ``` shell
217+ cp -r NekoThreadPool/include/ /path/to/your/include/
218+ ```
219+
220+ 3 . Include the header in your source code
221+
222+ ``` cpp
223+ #include < neko/core/threadPool.hpp>
132224```
133225
134226### Basic Usage
0 commit comments