]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/workq.h
Big backport from Enterprise
[bacula/bacula] / bacula / src / lib / workq.h
index a879834eac329da3e3a64ded08caf2400de47977..8952cceac593bf0a070b38556b3eed025922cb74 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2016 Kern Sibbald
+   Copyright (C) 2000-2017 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -43,6 +43,7 @@ typedef struct workq_ele_tag {
 typedef struct workq_tag {
    pthread_mutex_t   mutex;           /* queue access control */
    pthread_cond_t    work;            /* wait for work */
+   pthread_cond_t    idle;            /* wait for idle */
    pthread_attr_t    attr;            /* create detached threads */
    workq_ele_t       *first, *last;   /* work queue */
    int               valid;           /* queue initialized */
@@ -50,6 +51,7 @@ typedef struct workq_tag {
    int               max_workers;     /* max threads */
    int               num_workers;     /* current threads */
    int               idle_workers;    /* idle threads */
+   int               num_running;     /* Number of jobs running */
    void             *(*engine)(void *arg); /* user engine */
 } workq_t;
 
@@ -63,5 +65,7 @@ extern int workq_init(
 extern int workq_destroy(workq_t *wq);
 extern int workq_add(workq_t *wq, void *element, workq_ele_t **work_item, int priority);
 extern int workq_remove(workq_t *wq, workq_ele_t *work_item);
+extern int workq_wait_idle(workq_t *wq);
+
 
 #endif /* __WORKQ_H */