Skip to content

Commit fafab1e

Browse files
committed
feat: Update version to v1.0.2 , Enhance CMake configuration, improve module support, and update README for clarity
1 parent a6a477a commit fafab1e

File tree

6 files changed

+199
-105
lines changed

6 files changed

+199
-105
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.14)
2-
project(NekoThreadPool VERSION 1.0.0 LANGUAGES CXX)
2+
project(NekoThreadPool VERSION 1.0.2 LANGUAGES CXX)
33

44
# ================
55
# === Config ====
@@ -38,6 +38,7 @@ if(NEKO_THREAD_POOL_AUTO_FETCH_DEPS)
3838
GIT_REPOSITORY https://github.com/moehoshio/NekoSchema.git
3939
GIT_TAG main
4040
)
41+
set(NEKO_SCHEMA_BUILD_TESTS OFF CACHE BOOL "" FORCE)
4142
if (NEKO_THREAD_POOL_ENABLE_MODULE)
4243
set(NEKO_SCHEMA_ENABLE_MODULE ON CACHE BOOL "" FORCE)
4344
endif()
@@ -52,7 +53,6 @@ if(NEKO_THREAD_POOL_AUTO_FETCH_DEPS)
5253
GIT_REPOSITORY https://github.com/google/googletest.git
5354
GIT_TAG v1.17.0
5455
)
55-
# For Windows: Prevent overriding the parent project's compiler/linker settings
5656
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
5757
FetchContent_MakeAvailable(googletest)
5858
endif()
@@ -130,8 +130,8 @@ if(NEKO_THREAD_POOL_BUILD_TESTS)
130130
enable_testing()
131131
message(STATUS "NekoThreadPool tests enabled (NEKO_THREAD_POOL_BUILD_TESTS=ON)")
132132

133-
if (NOT GTEST_FOUND AND NOT NEKO_THREAD_POOL_AUTO_FETCH_DEPS)
134-
message(STATUS "GTest is required for building tests but was not found.")
133+
if (NOT Gtest_FOUND AND NOT NEKO_THREAD_POOL_AUTO_FETCH_DEPS)
134+
message(WARNING "GTest is required for building tests but was not found.")
135135
message(FATAL_ERROR "Please enable -DNEKO_THREAD_POOL_AUTO_FETCH_DEPS=ON or install GTest and make it discoverable by CMake. e.g -DCMAKE_PREFIX_PATH=</path/to/googletest>")
136136
endif()
137137

include/neko/thread/neko.thread.cppm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
module;
99

10-
#if !defined(__cpp_lib_modules) || (__cpp_lib_modules < 202207L)
10+
#if defined(__cpp_lib_modules) && (__cpp_lib_modules >= 202207L)
11+
import std;
12+
#else
1113
// Global module fragment - include headers that should not be exported
1214
#include <algorithm>
1315
#include <functional>
@@ -28,10 +30,11 @@ module;
2830
#include <string>
2931
#endif
3032

31-
export module neko.thread;
32-
3333
import neko.schema;
3434

35+
export module neko.thread;
36+
37+
// Control header files to not import dependencies (dependencies are declared and imported by the cppm)
3538
#define NEKO_THREAD_POOL_ENABLE_MODULE true
3639

3740
export {

include/neko/thread/threadPool.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
#pragma once
99

10-
#if !defined(NEKO_THREAD_POOL_ENABLE_MODULE)
10+
#if !defined(NEKO_THREAD_POOL_ENABLE_MODULE) || (NEKO_THREAD_POOL_ENABLE_MODULE == false)
1111
#include <neko/schema/exception.hpp>
1212
#include <neko/schema/types.hpp>
1313

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
{
2-
"version": "1.0.1",
3-
"port-version": 1,
4-
"name": "neko-threadpool",
5-
"description": "An easy-to-use and efficient C++ 20 thread pool that supports task priorities and task submission to specific threads.",
6-
"homepage": "https://github.com/moehoshio/NekoThreadPool",
7-
"license": "MIT OR Apache-2.0",
8-
"dependencies": [
9-
{
10-
"name": "vcpkg-cmake",
11-
"host": true
12-
},
13-
{
14-
"name": "vcpkg-cmake-config",
15-
"host": true
16-
},
17-
"neko-schema"
18-
]
19-
}
2+
"name": "neko-threadpool",
3+
"version": "1.0.1",
4+
"description": "An easy-to-use and efficient C++ 20 thread pool that supports task priorities and task submission to specific threads.",
5+
"homepage": "https://github.com/moehoshio/NekoThreadPool",
6+
"license": "MIT OR Apache-2.0",
7+
"dependencies": [
8+
"neko-schema",
9+
{
10+
"name": "vcpkg-cmake",
11+
"host": true
12+
},
13+
{
14+
"name": "vcpkg-cmake-config",
15+
"host": true
16+
}
17+
]
18+
}

readme.md

Lines changed: 136 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2627
Example: [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)
113191
target_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

Comments
 (0)