2 * Bacula job queue routines.
4 * Kern Sibbald, July MMIII
6 * This code adapted from Bacula work queue code, which was
7 * adapted from "Programming with POSIX Threads", by
13 Bacula® - The Network Backup Solution
15 Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
17 The main author of Bacula is Kern Sibbald, with contributions from
18 many others, a complete list can be found in the file AUTHORS.
19 This program is Free Software; you can redistribute it and/or
20 modify it under the terms of version two of the GNU General Public
21 License as published by the Free Software Foundation and included
24 This program is distributed in the hope that it will be useful, but
25 WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 General Public License for more details.
29 You should have received a copy of the GNU General Public License
30 along with this program; if not, write to the Free Software
31 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
34 Bacula® is a registered trademark of John Walker.
35 The licensor of Bacula is the Free Software Foundation Europe
36 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
37 Switzerland, email:ftf@fsfeurope.org.
44 * Structure to keep track of job queue request
52 * Structure describing a work queue
55 pthread_mutex_t mutex; /* queue access control */
56 pthread_cond_t work; /* wait for work */
57 pthread_attr_t attr; /* create detached threads */
58 dlist *waiting_jobs; /* list of jobs waiting */
59 dlist *running_jobs; /* jobs running */
60 dlist *ready_jobs; /* jobs ready to run */
61 int valid; /* queue initialized */
62 bool quit; /* jobq should quit */
63 int max_workers; /* max threads */
64 int num_workers; /* current threads */
65 int idle_workers; /* idle threads */
66 void *(*engine)(void *arg); /* user engine */
69 #define JOBQ_VALID 0xdec1993
73 int threads, /* maximum threads */
74 void *(*engine)(void *) /* engine routine */
76 extern int jobq_destroy(jobq_t *wq);
77 extern int jobq_add(jobq_t *wq, JCR *jcr);
78 extern int jobq_remove(jobq_t *wq, JCR *jcr);