1
/*
2
 * Copyright 2008-2011 Various Authors
3
 * Copyright 2004 Timo Hirvonen
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License as
7
 * published by the Free Software Foundation; either version 2 of the
8
 * License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful, but
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
#ifndef _WORKER_H
20
#define _WORKER_H
21
22
#define JOB_TYPE_NONE	0
23
#define JOB_TYPE_ANY	-1
24
25
void worker_init(void);
26
void worker_exit(void);
27
28
/*
29
 * @type:     JOB_TYPE_* (>0)
30
 * @job_cb:   does the job
31
 * @free_cb:  frees @data
32
 * @data:     data for the callbacks
33
 */
34
void worker_add_job(int type, void (*job_cb)(void *data),
35
		void (*free_cb)(void *data), void *data);
36
37
/*
38
 * @type: job type. >0, use JOB_TYPE_ANY to remove all
39
 */
40
void worker_remove_jobs(int type);
41
42
int worker_has_job(int type);
43
44
/*
45
 * @type: type of this job
46
 *
47
 * returns: 0 or 1
48
 *
49
 * long jobs should call this to see whether it should cancel
50
 * call from job function _only_
51
 */
52
int worker_cancelling(void);
53
54
#endif