#ifndef THREAD_POOL_INTERNAL_H
#define THREAD_POOL_INTERNAL_H
#include <pthread.h>
#include <stdint.h>
#include "htslib/thread_pool.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct hts_tpool_job {
void *(*func)(void *arg);
void *arg;
struct hts_tpool_job *next;
struct hts_tpool *p;
struct hts_tpool_process *q;
uint64_t serial;
} hts_tpool_job;
struct hts_tpool_result {
struct hts_tpool_result *next;
uint64_t serial; void *data; };
typedef struct {
struct hts_tpool *p;
int idx;
pthread_t tid;
pthread_cond_t pending_c; } hts_tpool_worker;
struct hts_tpool_process {
struct hts_tpool *p; hts_tpool_job *input_head; hts_tpool_job *input_tail;
hts_tpool_result *output_head; hts_tpool_result *output_tail;
int qsize; uint64_t next_serial; uint64_t curr_serial;
int n_input; int n_output; int n_processing;
int shutdown; int in_only; int wake_dispatch;
int ref_count;
pthread_cond_t output_avail_c; pthread_cond_t input_not_full_c; pthread_cond_t input_empty_c; pthread_cond_t none_processing_c;
struct hts_tpool_process *next, *prev;};
struct hts_tpool {
int nwaiting; int njobs; int shutdown;
hts_tpool_process *q_head;
int tsize; hts_tpool_worker *t;
int *t_stack, t_stack_top;
pthread_mutex_t pool_m;
int n_count, n_running;
long long total_time, wait_time;
};
#ifdef __cplusplus
}
#endif
#endif