2 * Bacula wait queue routines. Permits waiting for something
3 * to be done. I.e. for operator to mount new volume.
5 * Kern Sibbald, March MMI
7 * This code inspired from "Programming with POSIX Threads", by
14 Bacula® - The Network Backup Solution
16 Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
18 The main author of Bacula is Kern Sibbald, with contributions from
19 many others, a complete list can be found in the file AUTHORS.
20 This program is Free Software; you can redistribute it and/or
21 modify it under the terms of version two of the GNU General Public
22 License as published by the Free Software Foundation plus additions
23 that are listed in the file LICENSE.
25 This program is distributed in the hope that it will be useful, but
26 WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 General Public License for more details.
30 You should have received a copy of the GNU General Public License
31 along with this program; if not, write to the Free Software
32 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
35 Bacula® is a registered trademark ofJohn Walker.
36 The licensor of Bacula is the Free Software Foundation Europe
37 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
38 Switzerland, email:ftf@fsfeurope.org.
45 * Structure to keep track of wait queue request
47 typedef struct waitq_ele_tag {
48 struct waitq_ele_tag *next;
49 int done_flag; /* predicate for wait */
50 pthread_cont_t done; /* wait for completion */
51 void *msg; /* message to be passed */
55 * Structure describing a wait queue
57 typedef struct workq_tag {
58 pthread_mutex_t mutex; /* queue access control */
59 pthread_cond_t wait_req; /* wait for OK */
60 int num_msgs; /* number of waiters */
61 waitq_ele_t *first; /* wait queue first item */
62 waitq_ele_t *last; /* wait queue last item */
65 extern int waitq_init(waitq_t *wq);
66 extern int waitq_destroy(waitq_t *wq);
67 extern int waitq_add(waitq_t *wq, void *msg);
69 #endif /* __WAITQ_H */