]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/jobq.h
Mark translatable strings in all source files.
[bacula/bacula] / bacula / src / dird / jobq.h
1 /*
2  * Bacula job queue routines.
3  *
4  *  Kern Sibbald, July MMIII
5  *
6  *  This code adapted from Bacula work queue code, which was
7  *    adapted from "Programming with POSIX Threads", by
8  *    David R. Butenhof
9  *
10  *   Version $Id$
11  */
12 /*
13    Copyright (C) 2000-2004 Kern Sibbald and John Walker
14
15    This program is free software; you can redistribute it and/or
16    modify it under the terms of the GNU General Public License as
17    published by the Free Software Foundation; either version 2 of
18    the License, or (at your option) any later version.
19
20    This program is distributed in the hope that it will be useful,
21    but WITHOUT ANY WARRANTY; without even the implied warranty of
22    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23    General Public License for more details.
24
25    You should have received a copy of the GNU General Public
26    License along with this program; if not, write to the Free
27    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28    MA 02111-1307, USA.
29
30  */
31
32 #ifndef __JOBQ_H
33 #define __JOBQ_H 1
34
35 /*
36  * Structure to keep track of job queue request
37  */
38 struct jobq_item_t {
39    dlink link;
40    JCR *jcr;
41 };
42
43 /*
44  * Structure describing a work queue
45  */
46 struct jobq_t {
47    pthread_mutex_t   mutex;           /* queue access control */
48    pthread_cond_t    work;            /* wait for work */
49    pthread_attr_t    attr;            /* create detached threads */
50    dlist            *waiting_jobs;    /* list of jobs waiting */
51    dlist            *running_jobs;    /* jobs running */
52    dlist            *ready_jobs;      /* jobs ready to run */
53    int               valid;           /* queue initialized */
54    bool              quit;            /* jobq should quit */
55    int               max_workers;     /* max threads */
56    int               num_workers;     /* current threads */
57    int               idle_workers;    /* idle threads */
58    void             *(*engine)(void *arg); /* user engine */
59 };
60
61 #define JOBQ_VALID  0xdec1993
62
63 extern int jobq_init(
64               jobq_t *wq,
65               int     threads,            /* maximum threads */
66               void   *(*engine)(void *)   /* engine routine */
67                     );
68 extern int jobq_destroy(jobq_t *wq);
69 extern int jobq_add(jobq_t *wq, JCR *jcr);
70 extern int jobq_remove(jobq_t *wq, JCR *jcr);
71
72 #endif /* __JOBQ_H */