CTP is a C library that offers a pool thread, based on pthread, that is the only dependency. While easy to use, it has some interesting features:
Just compile the .c file and add it to your linker, as object or library. If using gcc/clang, remember to complie with -pthread and link with -lpthread
If you want to use visual studio, or other windows compiler, use package https://sourceware.org/pthreads-win32
While compiling ctp (The library, not the clients), you can pass these variables:
CTP_DEFAULT_THREADS_NUM is used only if you pass 0 to init, and ctp fails to detect core number.
In this case, CTP_DEFAULT_THREADS_NUM threads will be used. Default is 4.
If you pass 0 to init in the second parameter, the queue size will be calculated according to 3 parameters:
threads-num, CTP_MULTIPLY_QUEUE_FACTOR and CTP_MIN_QUEUE_SIZE. The formula is:
max(threads-num * CTP_MULTIPLY_QUEUE_FACTOR, CTP_MIN_QUEUE_SIZE)
The default value for CTP_MULTIPLY_QUEUE_FACTOR is 8.
The default value for CTP_MIN_QUEUE_SIZE is 256
For API details see header file. Test file may help too