Skip to content

Commit db10102

Browse files
committed
native/threadpool: disable multithreading on 32-bit platforms
1 parent 76f41c9 commit db10102

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

native/threadpool.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
#define IFCONSTEXPR
1414
#endif
1515

16+
#if defined(__LP64__)
17+
#define ALLOW_THREADS true
18+
#else
19+
#define ALLOW_THREADS false
20+
#endif
21+
1622
template <typename T, typename R> class ThreadPool {
1723
using processor_func_t = std::function<R(T &)>;
1824

@@ -28,7 +34,9 @@ template <typename T, typename R> class ThreadPool {
2834

2935
public:
3036
explicit ThreadPool(processor_func_t processor,
31-
const unsigned int thread_num = std::thread::hardware_concurrency())
37+
const unsigned int thread_num =
38+
ALLOW_THREADS ? std::thread::hardware_concurrency()
39+
: 1)
3240
: m_waker(), m_queue({}), m_stop(false), m_has_error(false),
3341
m_processor(std::move(processor)) {
3442
for (int i = 0; i < thread_num; ++i) {

0 commit comments

Comments
 (0)