naev
0.12.6
src
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
17
struct
ThreadQueue_
;
18
typedef
struct
ThreadQueue_
ThreadQueue;
19
20
/* Initializes the threadpool */
21
int
threadpool_init(
void
);
22
23
/* Creates a new vpool queue. Destroy with vpool_wait. */
24
ThreadQueue *vpool_create(
void
);
25
26
/* Enqueue a job in the vpool queue. Do NOT enqueue a job that has to wait for
27
* another job to be done as this could lead to a deadlock. Also do not enqueue
28
* jobs from enqueued threads. */
29
void
vpool_enqueue( ThreadQueue *queue,
int
( *function )(
void
* ),
30
void
*data );
31
32
/* Run every job in the vpool queue and block until every job in the queue is
33
* done. */
34
void
vpool_wait( ThreadQueue *queue );
35
36
/* Clean up. */
37
void
vpool_cleanup( ThreadQueue *queue );
ThreadQueue_
Threadqueue itself.
Definition
threadpool.c:63
Generated by
1.14.0