about summary refs log tree commit diff
path: root/src/engine/e_jobs.h
blob: 2b04a1e42ef0665ae784e9f0cb441b0b0927a5ff (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
31
32
33

typedef int (*JOBFUNC)(void *data);

typedef struct JOB
{
	struct JOBPOOL *pool;
	struct JOB *prev;
	struct JOB *next;
	volatile int status;
	volatile int result;
	JOBFUNC func;
	void *func_data;
} JOB;

typedef struct JOBPOOL
{
	LOCK lock;
	JOB *first_job;
	JOB *last_job;
} JOBPOOL;

enum
{
	JOBSTATUS_PENDING=0,
	JOBSTATUS_RUNNING,
	JOBSTATUS_DONE
	/*JOBSTATUS_ABORTING,*/
	/*JOBSTATUS_ABORTED,*/
};

int jobs_initpool(JOBPOOL *pool, int num_threads);
int jobs_add(JOBPOOL *pool, JOB *job, JOBFUNC func, void *data);
int jobs_status(JOB *job);