|
Crinit -- Configurable Rootfs Init
|
Implementations of a generic worker thread pool. Used by the notification/service interface to handle socket communication. More...
#include "thrpool.h"#include <stdbool.h>#include <stdlib.h>#include <string.h>#include "logio.h"
Macros | |
| #define | crinitDryPoolThreshold(poolSize) ((poolSize) / 10) |
Functions | |
| static int | crinitThreadPoolGrow (crinitThreadPool_t *ctx, size_t newSize) |
| static void * | crinitDryPoolWatchdog (void *thrpool) |
| int | crinitThreadPoolInit (crinitThreadPool_t *ctx, size_t initialSize, void *(*threadFunc)(void *), const void *thrArgs, size_t thrArgsSize) |
| int | crinitThreadPoolThreadBusyCallback (crinitThreadPool_t *ctx) |
| int | crinitThreadPoolThreadAvailCallback (crinitThreadPool_t *ctx) |
Implementations of a generic worker thread pool. Used by the notification/service interface to handle socket communication.
| #define crinitDryPoolThreshold | ( | poolSize | ) | ((poolSize) / 10) |
Function macro to calculate threshold value at and below which point the pool is considerd "dry".
| poolSize | The current total size of the worker thread pool. |
|
static |
Thread function to monitor the current load of the thread pool and grow its size if needed.
To be started as a pthread running alongside the worker threads. Will monitor the given thread pool via crinitThreadPool_t::threadAvail and crinitThreadPool_t::threadAvailChanged.
A "dry pool" condition is detected and the thread pool grown if 90% or more of the pool's worker threads are currently unavailable.
| thrpool | The crinitThreadPool_t to monitor. |
|
static |
Grow the given thread pool to the given new size.
Gets called by the dryPoolWatchdog() if not enough threads are idle/available.
| ctx | The thread pool to grow. |
| newSize | The new size of the thread pool, must be larger than the old size. |
| int crinitThreadPoolInit | ( | crinitThreadPool_t * | ctx, |
| size_t | initialSize, | ||
| void *(*)(void *) | threadFunc, | ||
| const void * | thrArgs, | ||
| size_t | thrArgsSize | ||
| ) |
Initialize an crinitThreadPool_t.
| ctx | The crinitThreadPool_t to initialize. |
| initialSize | Initial size (in number of threads) of the pool. |
| threadFunc | Worker thread function to use. |
| thrArgs | Arguments to the worker thread function. Will be copied and saved in case more threads need to be started by dryPoolWatchdog. |
| thrArgsSize | Size (Bytes) of arguments to the worker thread function. |
| int crinitThreadPoolThreadAvailCallback | ( | crinitThreadPool_t * | ctx | ) |
Callback to be used by the worker thread function signalling it is idle/available.
| ctx | The crinitThreadPool_t context. |
| int crinitThreadPoolThreadBusyCallback | ( | crinitThreadPool_t * | ctx | ) |
Callback to be used by the worker thread function signalling it is busy/unavailable.
| ctx | The crinitThreadPool_t context. |