blob: f318a38be8dd94a768b2b0b6215ed7993ab3207f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/*
* blogc: A blog compiler.
* Copyright (C) 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br>
*
* This program can be distributed under the terms of the BSD License.
* See the file LICENSE.
*/
#ifndef _THREAD_POOL_H
#define _THREAD_POOL_H
#include <pthread.h>
#include "utils.h"
typedef void (*bc_threadpool_func_t) (void *job, void *user_data);
typedef struct {
bc_slist_t *jobs;
pthread_mutex_t jobs_mutex;
bc_slist_t *threads;
size_t max_threads;
bc_threadpool_func_t func;
void *user_data;
} bc_threadpool_t;
bc_threadpool_t* bc_threadpool_new(bc_threadpool_func_t func,
size_t max_threads, void *user_data, bc_error_t **err);
void bc_threadpool_append(bc_threadpool_t *pool, void *user_data);
#endif /* _THREAD_POOL_H */
|