naev 0.11.5
threadpool.h
1/* Copyright 2010 Reynir Reynisson
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 3 as
5 * published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 */
15#pragma once
16
17struct ThreadQueue_;
18typedef struct ThreadQueue_ ThreadQueue;
19
20/* Initializes the threadpool */
21int threadpool_init (void);
22
23/* Enqueues a new job */
24int threadpool_newJob( int (*function)(void *), void *data );
25
26/* Creates a new vpool queue. Destroy with vpool_wait. */
27ThreadQueue* vpool_create (void);
28
29/* Enqueue a job in the vpool queue. Do NOT enqueue a job that has to wait for
30 * another job to be done as this could lead to a deadlock. */
31void vpool_enqueue( ThreadQueue* queue, int (*function)(void *), void *data );
32
33/* Run every job in the vpool queue and block until every job in the queue is
34 * done. It destroys the queue when it's done. */
35void vpool_wait( ThreadQueue* queue );
Threadqueue itself.
Definition threadpool.c:59