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 Copyright (C) 2000-2004 Kern Sibbald and John Walker
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.
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.
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,
36 * Structure to keep track of job queue request
44 * Structure describing a work queue
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 */
61 #define JOBQ_VALID 0xdec1993
65 int threads, /* maximum threads */
66 void *(*engine)(void *) /* engine routine */
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);