2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2017 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * Bacula job queue routines.
22 * Kern Sibbald, July MMIII
24 * This code adapted from Bacula work queue code, which was
25 * adapted from "Programming with POSIX Threads", by
33 * Structure to keep track of job queue request
41 * Structure describing a work queue
44 pthread_mutex_t mutex; /* queue access control */
45 pthread_cond_t work; /* wait for work */
46 pthread_attr_t attr; /* create detached threads */
47 dlist *waiting_jobs; /* list of jobs waiting */
48 dlist *running_jobs; /* jobs running */
49 dlist *ready_jobs; /* jobs ready to run */
50 int valid; /* queue initialized */
51 bool quit; /* jobq should quit */
52 int max_workers; /* max threads */
53 int num_workers; /* current threads */
54 int idle_workers; /* idle threads */
55 void *(*engine)(void *arg); /* user engine */
58 #define JOBQ_VALID 0xdec1993
62 int threads, /* maximum threads */
63 void *(*engine)(void *) /* engine routine */
65 extern int jobq_destroy(jobq_t *wq);
66 extern int jobq_add(jobq_t *wq, JCR *jcr);
67 extern int jobq_remove(jobq_t *wq, JCR *jcr);