MAOS
Multithreaded Adaptive Optics Simulator
Loading...
Searching...
No Matches
thread_pool.h File Reference

Data Structures

struct  tp_counter_t

Macros

#define ENABLE_TP_TIMING   0
 define to 1 to enable report of timing for each thread launch. Reduce number of threads when timing is small.

Functions

struct tp_counter_t __attribute__ ((unused))
void thread_pool_init (unsigned int nthread)
void thread_pool_queue (tp_counter_t *counter, thread_wrapfun fun, void *arg, int njob, int urgent)
void thread_pool_wait (tp_counter_t *counter, int urgent)
void thread_pool_wait_all (void)
void thread_pool_destroy (void)

Detailed Description

Contains implementation of a thread pool.


Data Structure Documentation

◆ tp_counter_t

struct tp_counter_t
Collaboration diagram for tp_counter_t:
Data Fields
unsigned int group

Function Documentation

◆ thread_pool_init()

void thread_pool_init ( unsigned int nthread)

Initialize the thread pool. Repeated call to resize the pool

◆ thread_pool_queue()

void thread_pool_queue ( tp_counter_t * counter,
thread_wrapfun fun,
void * arg,
int njob,
int urgent )

Queue jobs that belongs to group denoted by group. The argument group, will be incremented by 1 for each job queued and decreased by 1 after each job is finished. Wait on it will clear when count is decreased to zero.

Job is added to jobsnormal or joburgent depending on urgent value

◆ thread_pool_wait()

void thread_pool_wait ( tp_counter_t * counter,
int urgent )

Wait for jobs in the count to be done. Has the potential to deadlock if it calls do_job and the job inside calls pthread_cond_wait.

◆ thread_pool_wait_all()

void thread_pool_wait_all ( void )

Wait for all jobs to be done.

◆ thread_pool_destroy()

void thread_pool_destroy ( void )

Exit all threads and free thread pool.