#pragma once #include #include typedef void (*lm_thfunc_t)(void *arg); typedef struct lm_thwork_t { lm_thfunc_t func; void *arg; struct lm_thwork_t *next; } lm_thwork_t; typedef struct lm_thpool_t { pthread_mutex_t mutex; pthread_cond_t work_lock; pthread_cond_t thread_lock; size_t active; size_t all; lm_thwork_t *first; lm_thwork_t *last; bool stop; } lm_thpool_t; bool lm_thpool_init(lm_thpool_t *tp, int n); bool lm_thpool_add(lm_thpool_t *tp, lm_thfunc_t func, void *data); void lm_thpool_stop(lm_thpool_t *tp);