2 Bacula® - The Network Backup Solution
4 Copyright (C) 2001-2009 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version three of the GNU Affero General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
29 * Bacula work queue routines. Permits passing work to
32 * Kern Sibbald, January MMI
34 * This code adapted from "Programming with POSIX Threads", by
44 * Structure to keep track of work queue request
46 typedef struct workq_ele_tag {
47 struct workq_ele_tag *next;
52 * Structure describing a work queue
54 typedef struct workq_tag {
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 workq_ele_t *first, *last; /* work queue */
59 int valid; /* queue initialized */
60 int quit; /* workq should quit */
61 int max_workers; /* max threads */
62 int num_workers; /* current threads */
63 int idle_workers; /* idle threads */
64 void *(*engine)(void *arg); /* user engine */
67 #define WORKQ_VALID 0xdec1992
69 extern int workq_init(
71 int threads, /* maximum threads */
72 void *(*engine)(void *) /* engine routine */
74 extern int workq_destroy(workq_t *wq);
75 extern int workq_add(workq_t *wq, void *element, workq_ele_t **work_item, int priority);
76 extern int workq_remove(workq_t *wq, workq_ele_t *work_item);
78 #endif /* __WORKQ_H */