Struct in stdx_thread.h

XThreadPool

typedef struct XThreadPool XThreadPool;
Typedef in stdx_thread.h

XThreadTask

typedef void(*XThreadTask)(void *arg);
Function in stdx_thread.h

x_threadpool_create

Create a thread pool with a fixed number of worker threads.

XThreadPool * x_threadpool_create(int num_threads);

Parameters

int num_threads
Number of worker threads to start.

Returns

Thread pool handle, or NULL on failure.

Function in stdx_thread.h

x_threadpool_destroy

Destroy a thread pool and release its resources.

void x_threadpool_destroy(XThreadPool *pool);

Parameters

XThreadPool *pool
Thread pool handle.
Function in stdx_thread.h

x_threadpool_enqueue

Enqueue a task for execution by the thread pool.

int32_t x_threadpool_enqueue(
 XThreadPool *pool,
 XThreadTask fn,
 void *arg
);

Parameters

XThreadPool *pool
Thread pool handle.
XThreadTask fn
Task function to execute.
void *arg
User argument passed to fn.

Returns

0 on success, non-zero on failure.