my thread_pool library writen in c
- C compiler that supports C11 and thread.h + stdatomic.h
- CMake (version 3.10 or later)
- git
Clone repository:
git clone https://github.com/fogInSingularity/thread_pool.gitNavigate to the project directory:
cd thread_poolConfigure and build project:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel `nproc`If you want to run tests: Configure and build project:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON
cmake --build build --parallel `nproc`typedef enum {
ThreadPoolError_kOk = 0,
ThreadPoolError_kTaskQueueFull = 1,
} ThreadPoolError;
typedef struct ThreadPool ThreadPool;
typedef void (*TaskFunc)(void* task_arg);
ThreadPool* ThreadPoolCreate(size_t n_threads, size_t queue_size);
void ThreadPoolDestroy(ThreadPool* thread_pool);
ThreadPoolError ThreadPoolQueueTask(ThreadPool* thread_pool, TaskFunc task_func, void* task_arg);