Crinit -- Configurable Rootfs Init
thrpool.h File Reference

(2023-11-21, commit: e767693)

Header defining a generic worker thread pool. Used by the notification/service interface to handle socket communication. More...

#include <limits.h>
#include <pthread.h>
Include dependency graph for thrpool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  crinitThreadPool_t
 

Macros

#define CRINIT_THREADPOOL_DEFAULT_INITIAL_SIZE   8
 
#define CRINIT_THREADPOOL_THREAD_STACK_SIZE   (PTHREAD_STACK_MIN + 112 * 1024)
 

Typedefs

typedef struct crinitThreadPool_t crinitThreadPool_t
 

Functions

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)
 

Detailed Description

Header defining a generic worker thread pool. Used by the notification/service interface to handle socket communication.

Macro Definition Documentation

◆ CRINIT_THREADPOOL_DEFAULT_INITIAL_SIZE

#define CRINIT_THREADPOOL_DEFAULT_INITIAL_SIZE   8

Default initial size (in number of threads) of the thread pool

◆ CRINIT_THREADPOOL_THREAD_STACK_SIZE

#define CRINIT_THREADPOOL_THREAD_STACK_SIZE   (PTHREAD_STACK_MIN + 112 * 1024)

Stack size of the threads within the thread pool.

Typedef Documentation

◆ crinitThreadPool_t

Structure holding a worker thread pool.

Function Documentation

◆ crinitThreadPoolInit()

int crinitThreadPoolInit ( crinitThreadPool_t ctx,
size_t  initialSize,
void *(*)(void *)  threadFunc,
const void *  thrArgs,
size_t  thrArgsSize 
)

Initialize an crinitThreadPool_t.

Parameters
ctxThe crinitThreadPool_t to initialize.
initialSizeInitial size (in number of threads) of the pool.
threadFuncWorker thread function to use.
thrArgsArguments to the worker thread function. Will be copied and saved in case more threads need to be started by dryPoolWatchdog.
thrArgsSizeSize (Bytes) of arguments to the worker thread function.
Returns
0 on success, -1 otherwise

◆ crinitThreadPoolThreadAvailCallback()

int crinitThreadPoolThreadAvailCallback ( crinitThreadPool_t ctx)

Callback to be used by the worker thread function signalling it is idle/available.

Parameters
ctxThe crinitThreadPool_t context.
Returns
0 on success, -1 otherwise

◆ crinitThreadPoolThreadBusyCallback()

int crinitThreadPoolThreadBusyCallback ( crinitThreadPool_t ctx)

Callback to be used by the worker thread function signalling it is busy/unavailable.

Parameters
ctxThe crinitThreadPool_t context.
Returns
0 on success, -1 otherwise