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) 2001-2006 Kern Sibbald
16 This program is free software; you can redistribute it and/or
17 modify it under the terms of the GNU General Public License
18 version 2 as amended with additional clauses defined in the
19 file LICENSE in the main source directory.
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
24 the file LICENSE for additional details.
32 * Structure to keep track of wait queue request
34 typedef struct waitq_ele_tag {
35 struct waitq_ele_tag *next;
36 int done_flag; /* predicate for wait */
37 pthread_cont_t done; /* wait for completion */
38 void *msg; /* message to be passed */
42 * Structure describing a wait queue
44 typedef struct workq_tag {
45 pthread_mutex_t mutex; /* queue access control */
46 pthread_cond_t wait_req; /* wait for OK */
47 int num_msgs; /* number of waiters */
48 waitq_ele_t *first; /* wait queue first item */
49 waitq_ele_t *last; /* wait queue last item */
52 extern int waitq_init(waitq_t *wq);
53 extern int waitq_destroy(waitq_t *wq);
54 extern int waitq_add(waitq_t *wq, void *msg);
56 #endif /* __WAITQ_H */