A very basic thread pool implementation in C.
./build.sh
./bin/tpool-example
Send SIGUSR1 signal to add a task to the pool.
Note: This is a very basic implementation, more features will be added in the near future.
Include the src/tpool.h
file into your project, and add src/tpool.c
during compilation.
- Creating a thread pool
int tpool_init(tpool *pool, size_t thread_count);
- Adding a task to the pool
ssize_t tpool_add_task(tpool *pool, void* (*start_routine)(void*), void* args);
returns: -1 on error, otherwise gives the assigned task id
- Destroying thread pool
int tpool_destroy(tpool *pool);