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 Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
16 This program is free software; you can redistribute it and/or
17 modify it under the terms of the GNU General Public License as
18 published by the Free Software Foundation; either version 2 of
19 the License, or (at your option) any later version.
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
26 You should have received a copy of the GNU General Public
27 License along with this program; if not, write to the Free
28 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
37 * Structure to keep track of wait queue request
39 typedef struct waitq_ele_tag {
40 struct waitq_ele_tag *next;
41 int done_flag; /* predicate for wait */
42 pthread_cont_t done; /* wait for completion */
43 void *msg; /* message to be passed */
47 * Structure describing a wait queue
49 typedef struct workq_tag {
50 pthread_mutex_t mutex; /* queue access control */
51 pthread_cond_t wait_req; /* wait for OK */
52 int num_msgs; /* number of waiters */
53 waitq_ele_t *first; /* wait queue first item */
54 waitq_ele_t *last; /* wait queue last item */
57 extern int waitq_init(waitq_t *wq);
58 extern int waitq_destroy(waitq_t *wq);
59 extern int waitq_add(waitq_t *wq, void *msg);
61 #endif /* __WAITQ_H */