Nilorea Library
C utilities for networking, threading, graphics
n_thread_pool.c File Reference

Thread pool functions. More...

#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_thread_pool.h"
#include "nilorea/n_time.h"
#include <unistd.h>
#include <pthread.h>
#include <string.h>
#include <errno.h>
+ Include dependency graph for n_thread_pool.c:

Go to the source code of this file.

Functions

int add_threaded_process (THREAD_POOL *thread_pool, void *(*func_ptr)(void *param), void *param, int mode)
 add a function and params to a thread pool More...
 
int destroy_threaded_pool (THREAD_POOL **pool, int delay)
 delete a thread_pool, exit the threads and free the structs More...
 
int get_nb_cpu_cores ()
 get number of core of current system More...
 
THREAD_POOLnew_thread_pool (int nbmaxthr, int nb_max_waiting)
 Create a new pool of nbmaxthr threads. More...
 
int refresh_thread_pool (THREAD_POOL *thread_pool)
 try to add some waiting DIRECT_PROCs on some free thread slots, else do nothing More...
 
int start_threaded_pool (THREAD_POOL *thread_pool)
 Launch the process waiting for exectution in the thread pool. More...
 
void * thread_pool_processing_function (void *param)
 Internal thread pool processing function. More...
 
int wait_for_synced_threaded_pool (THREAD_POOL *thread_pool)
 wait for all the launched process, blocking but light on the CPU as there is no polling More...
 
int wait_for_threaded_pool (THREAD_POOL *thread_pool, int delay)
 Wait for all the launched process in the thread pool to terminate. More...
 

Detailed Description

Thread pool functions.

Author
Castagnier Mickael
Version
1.0
Date
30/04/2014

Definition in file n_thread_pool.c.

Function Documentation

◆ thread_pool_processing_function()

void * thread_pool_processing_function ( void *  param)

Internal thread pool processing function.

Parameters
paramTeh eventual param of a process
Returns
NULL when exiting

Definition at line 47 of file n_thread_pool.c.

References EXITED_THREAD, EXITING_THREAD, IDLE_PROC, LOG_DEBUG, LOG_ERR, n_log, refresh_thread_pool(), RUNNING_PROC, RUNNING_THREAD, and SYNCED_PROC.

Referenced by new_thread_pool().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: