summaryrefslogtreecommitdiffstats
path: root/libnetdata/completion/completion.h
blob: 723f736889666b9187f1de1502d098a70af2040b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef NETDATA_COMPLETION_H
#define NETDATA_COMPLETION_H

#include "../libnetdata.h"

struct completion {
    uv_mutex_t mutex;
    uv_cond_t cond;
    volatile unsigned completed;
    volatile unsigned completed_jobs;
};

void completion_init(struct completion *p);

void completion_destroy(struct completion *p);

void completion_wait_for(struct completion *p);

void completion_mark_complete(struct completion *p);

unsigned completion_wait_for_a_job(struct completion *p, unsigned completed_jobs);
void completion_mark_complete_a_job(struct completion *p);
bool completion_is_done(struct completion *p);

#endif /* NETDATA_COMPLETION_H */