summaryrefslogtreecommitdiff
path: root/tpool.h
blob: d03f70aac82ede1c9470129054f62fc75b837b6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef THREAD_POOL_H
#define THREAD_POOL_H

#include <pthread.h>
#include <stdbool.h>

typedef void (*thread_func_t)(void *arg);

typedef struct {
	thread_func_t function;
	void *arg;
} ThreadPoolJob;

typedef struct ThreadPool ThreadPool;

ThreadPool *tp_create(int num_threads);
void tp_add_job(ThreadPool *pool, thread_func_t function, void *arg);
void tp_wait(ThreadPool *pool);
void tp_destroy(ThreadPool *pool);

#endif