Skip to content

Commit 7d784b4

Browse files
committed
addressing compat issue seen with jthread
1 parent ddf8150 commit 7d784b4

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

include/sqlite-vec-cpp/index/hnsw_threading.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
#include <thread>
88
#include <vector>
99

10+
// C++20 jthread support check
11+
#if __has_include(<version>)
12+
#include <version>
13+
#endif
14+
15+
#if defined(__cpp_lib_jthread) && (__cpp_lib_jthread >= 201911L)
16+
#define SQLITE_VEC_CPP_HAS_JTHREAD 1
17+
#else
18+
#define SQLITE_VEC_CPP_HAS_JTHREAD 0
19+
#endif
20+
1021
namespace sqlite_vec_cpp::index {
1122

1223
/// Simple spinlock using atomic flag
@@ -224,7 +235,11 @@ class StripedLockManager {
224235
/// Thread pool executor for parallel operations
225236
class ThreadPool {
226237
size_t num_threads_;
238+
#if SQLITE_VEC_CPP_HAS_JTHREAD
227239
std::vector<std::jthread> threads_;
240+
#else
241+
std::vector<std::thread> threads_;
242+
#endif
228243
std::atomic<size_t> next_idx_{0};
229244

230245
public:

0 commit comments

Comments
 (0)