Skip to content

Commit d6ce3dc

Browse files
Add very preliminary threadpool implementation.
1 parent aa3d8a8 commit d6ce3dc

File tree

3 files changed

+430
-0
lines changed

3 files changed

+430
-0
lines changed

include/qt_threadpool.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef QT_THREADPOOL_H
2+
#define QT_THREADPOOL_H
3+
4+
#include <stdint.h>
5+
6+
#include <qthread/common.h>
7+
8+
typedef int (*qt_threadpool_func_type)(void *);
9+
10+
typedef enum {
11+
POOL_INIT_SUCCESS,
12+
POOL_INIT_ALREADY_INITIALIZED,
13+
POOL_INIT_NO_THREADS_SPECIFIED,
14+
POOL_INIT_OUT_OF_MEMORY,
15+
// TODO: better granularity when forwarding errors from thread creation.
16+
POOL_INIT_ERROR
17+
} hw_pool_init_status;
18+
19+
hw_pool_init_status hw_pool_init(uint32_t num_threads);
20+
void hw_pool_destroy();
21+
void hw_pool_run_on_all(qt_threadpool_func_type func, void *arg);
22+
23+
#endif

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ set(QTHREADS_SOURCES
3535
alloc/${QTHREADS_ALLOC}.c
3636
affinity/common.c
3737
affinity/${QTHREADS_TOPOLOGY}.c
38+
threadpool.c
3839
touch.c
3940
tls.c
4041
teams.c

0 commit comments

Comments
 (0)