completion.h 690 B

123456789101112131415161718192021222324252627
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_COMPLETION_H
  3. #define NETDATA_COMPLETION_H
  4. #include "../libnetdata.h"
  5. struct completion {
  6. uv_mutex_t mutex;
  7. uv_cond_t cond;
  8. volatile unsigned completed;
  9. volatile unsigned completed_jobs;
  10. };
  11. void completion_init(struct completion *p);
  12. void completion_destroy(struct completion *p);
  13. void completion_wait_for(struct completion *p);
  14. void completion_mark_complete(struct completion *p);
  15. unsigned completion_wait_for_a_job(struct completion *p, unsigned completed_jobs);
  16. void completion_mark_complete_a_job(struct completion *p);
  17. bool completion_is_done(struct completion *p);
  18. #endif /* NETDATA_COMPLETION_H */